Chud37 Posted April 24, 2012 Share Posted April 24, 2012 I need to match (Click to Enlarge) WITH the brackets. Its at the bottom of thumbnails and I want to remove it. I cannot work out what REGEX to use, Im new to it! So far i've got: {\(Click to Enlarge\)} But that is returning nothing. Could someone please tell me what the best thing to use is and why! Quote Link to comment https://forums.phpfreaks.com/topic/261528-quick-regex-help-needed/ Share on other sites More sharing options...
joe92 Posted April 24, 2012 Share Posted April 24, 2012 You almost had it. The pattern delimiter's need to be identical, although I would strongly advise against using the squiggly brackets for them. I would suggest the tilde in this case. Try: ~\(Click To Enlarge\)~ Quote Link to comment https://forums.phpfreaks.com/topic/261528-quick-regex-help-needed/#findComment-1340095 Share on other sites More sharing options...
Adam Posted April 25, 2012 Share Posted April 25, 2012 The pattern delimiter's need to be identical Not quite true. You can also use a pair of matching bracket-type characters such as <> and {}. I'm not sure why the regex you posted originally didn't work for you Chud37, it worked for me. Although there's really no need to use regex for simple string replacing. This would be much quicker: $str = str_replace('(Click to Enlarge)', '', $str); Quote Link to comment https://forums.phpfreaks.com/topic/261528-quick-regex-help-needed/#findComment-1340380 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.