Forum Moderators: open

Message Too Old, No Replies

Regexp pattern

bbcode etc

         

cruentus

9:36 pm on Jan 1, 2006 (gmt 0)



Hey,

I'm trying to write a pattern that will replace bbcode in my forum. Right now I have 2 separate patterns for the url tags. One for [ url]bleh[/url ] and one for [ url=blah]bleh[/url ] (without spaces), but I want it in the same pattern if it's possible. I'm new to ASP, so this is probably something very simple. I've searched around for it, but couldn't find any help on it though.

Right now the pattern looks like this:

"\[url=([^\]]+)\]([^\]]+)\[\/url\]"

So I want the equal sign and the text that follows to be "1 or no times". Is there any way to do this?

emsaw

11:06 pm on Jan 4, 2006 (gmt 0)

10+ Year Member



cruentus,

a ? means zero or one of the previous expression.
you could also use {0,1}

[a-zA-Z]?
[a-zA-Z]{0,1}

are the same thing in this example, which means 0 or 1 letters between a and Z

HTH,

mark