Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex Special Characters

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi All

This problem was raised in this forum in thread855-493222 but didnt seem to be addressed. I have a regex for say stripping attributes from tags something like..

Regex rxStriptAttributes = new Regex(&quot;(<\w+)[^>](>)&quot;);

all well and good as far as the regex doing the job. When i try and build this in VS.NET i get the error

&quot;Unrecognized Escape Sequence&quot;

caused by the regex special character '\w' as VS is obviously looking for a string escape not a regex special character. Now i can replace '\w' in this case with [a-zA-Z] but what if i wished to use \b or \n for a multiline match.....

Whats going on here - all the examples i see anywhere describe the use of special charcters in this way and none mention compilation problems. I am using all the correct namespaces and the code builds and runs fine if the '\w' is replaced. Is this VS 'bug' or am i missing something here?

Cheers

Rob

------------------------------------

Go placidly amidst the noise and haste,
find what peace there may be in silence.
-Anon

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top