hoachen Posted September 6, 2006 Share Posted September 6, 2006 I am stuck on working replace a string text. I want to find all the files that contain extension of jpg and jpeg and then replace them without the extension but the filename will remain and echo out the filename without extension.I tried the below but not working!! Please help me to resolve this.$str = /.*\(.gif|jpg|jpeg) //find all the files that have the jpg, jpeg, gif extension on a "image" folder$text = preg_replace(/.$,$str)print_r($text);?>cheerhoachen Link to comment Share on other sites More sharing options...
justsomeguy Posted September 6, 2006 Share Posted September 6, 2006 That regular expression isn't correct. Try this to start with:$str = "/^.*(\\.gif|\\.jpg|\\.jpeg)\$/";Also, make sure you have semicolons at the end of your lines.What is the purpose of "/.$" in the below line?$text = preg_replace(/.$,$str) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now