Regular Expression Problem

  • Thread starter Thread starter Manzi [MVP]
  • Start date Start date
M

Manzi [MVP]

Hi Guys,

Check the following code. I just used them in the Page_Load of an ASP.Net
page.

------------------------------------------------------------------------------
//using System.Text.RegularExpressions;

Regex regex = new Regex("real~(ity)");

Response.Write(regex.Match("realty").Success.ToString()); // Returns
False
Response.Write(regex.Match("really").Success.ToString()); // Returns
False
Response.Write(regex.Match("reality").Success.ToString()); // Returns
False
------------------------------------------------------------------------------

According to MSDN, the first two lines should return True. But when I check
this in VS2005 Beta2, it returns false for the first two lines.
Any reason you can think about?

Thanks

Manzi
 
What is the link to that MSDN article. Does the character "~" have any
special meaning in regex?

I think only exp like "real~ity" would match.
 
The only string that would match that is "real~ity".

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.
 
Back
Top