Support Forums

Full Version: Regex, exclude part of string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.