Support Forums
Regex, exclude part of string - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Regex, exclude part of string (/showthread.php?tid=18989)



Regex, exclude part of string - Bencori - 05-25-2011

Hi,

I'm trying to make a regex that would return only a number from a BBCode string. Like this:

Code:
[bbcode=50]bla bla bla bla[/bbcode]

I only want "50". So I could do it the dirty way, but I'm looking for a better way to "exclude" 50.

So I make my pattern, like this:

Code:
#\[bbcode\=[0-9]*\](.*?)\[\/bbcode\]#

I think the expression above should match anything between my tags.

Now, what I'm trying to extract the number before the replace. Anyone knows how to do this?

Thanks.






RE: Regex, exclude part of string - Gaijin - 05-25-2011

http://www.supportforums.net/showthread.php?tid=1676 (3rd preg_replace)