Danielx64 Posted November 1, 2016 Share Posted November 1, 2016 (edited) Hello all, I'm trying to write a preg_replace_callback(); function that would find [attachment=0]14547801_194886730949087_6033257422456356864_n.jpg[/attachment] Right now I have tried using #\[attachment=([0-9]+)\](.*?)\[\/attachment\]# and basically nuke it. but it doesn't seems to be working. My current code looks like this: $resume_text = preg_replace_callback('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#', "callback", $resume_text); function callback($match) { return $match; } Could someone please tell me where I am going wrong? https://regex101.com/r/LUhkmp/1 Link to comment https://www.neowin.net/forum/topic/1312818-having-trouble-with-preg_replace_callback/ Share on other sites More sharing options...
0 jamieakers Posted December 2, 2016 Share Posted December 2, 2016 (edited) Something like this? (?<=(\[attachment=[0-9]\]))(.*)(?=\[\/attachment) https://regex101.com/r/LUhkmp/3 FWIW I find regexr much more user-friendly. Same thing on their site: http://regexr.com/v1?394tp Link to comment https://www.neowin.net/forum/topic/1312818-having-trouble-with-preg_replace_callback/#findComment-597688728 Share on other sites More sharing options...
Question
Danielx64
Hello all,
I'm trying to write a
preg_replace_callback(); function that would find
Right now I have tried using
#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#
and basically nuke it.
but it doesn't seems to be working. My current code looks like this:
Could someone please tell me where I am going wrong?
https://regex101.com/r/LUhkmp/1
Link to comment
https://www.neowin.net/forum/topic/1312818-having-trouble-with-preg_replace_callback/Share on other sites
1 answer to this question
Recommended Posts