Forum Moderators: open

Message Too Old, No Replies

Regular Expression Help

Replacing brackets [

         

digitalv

2:55 am on Aug 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to set a RegEx pattern [quote] for replacement later. How do I do this? It's treating the brackets as part of the RegEx code and not as text and I'm not sure what to do to get around that.

TheNige

3:08 am on Aug 9, 2005 (gmt 0)

10+ Year Member



you need to use the escape character

\[
or
\]

MSDN has a list of all the special characters.

digitalv

3:49 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok last RegEx question for a while ... how can I turn this:

[link]http://www.sample.com[/link]

into this:

<a href="http://www.sample.com">http://www.sample.com</a>

Using a regular expression?

TheNige

12:05 am on Aug 19, 2005 (gmt 0)

10+ Year Member



Regex.Replace("http://www.example.com","(\bhttp://[^ ]+\b)", "<a href=""$0"">$0</a>")

you'll have to figure out the [link] tags in the replace.