Disturbed One Posted April 6, 2011 Share Posted April 6, 2011 Hello, I am a long-time PHP coder, but can never figure out Regex! I am trying to display text that has various tags in it, such as Hello {tag_name_here} etc. How can I replace all instances of these tags so the output would be Hello <span class="blah">{tag_name_here}</span>? Note the { and } need to stay intact surrounding the tag. Thanks! Link to comment https://forums.phpfreaks.com/topic/232910-look-for-strings-and-add-html/ Share on other sites More sharing options...
JAY6390 Posted April 6, 2011 Share Posted April 6, 2011 $result = preg_replace('/(\{[a-z0-9_]+\})/i', '<span class="blah">$1</span>', $subject); Link to comment https://forums.phpfreaks.com/topic/232910-look-for-strings-and-add-html/#findComment-1197953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.