PC Review

Thread Tools Rate Thread

Regex Error - unrecognized escape sequence

Posts: n/a
      31st Mar 2005
I'm trying to validate input from a textbox in the code-behind of my page.
I don't want to use any validator controls for this, I'd like to do it all in
the code behind. However, I'm getting an "unrecognized escape sequence"
compile error. Can someone please help me determine the correct regular
expression statement? I'm trying to validate that the textbox only contains
"Safe" characters (digits, letters, spaces, periods, etc).

Here is my code:

//Validate for safe characters
Regex r = new Regex("^[a-zA-Z0-9\\s.\\-]+$");

if (!r.IsMatch(txtUVNONumber.Text))
lblErrorMessage.Text = "Invalid entry for UVNO Number";
lblErrorMessage.Visible = true;
Reply With Quote
Cor Ligthert
Posts: n/a
      31st Mar 2005

Did you try this already

Regex r = new Regex(@"^[a-zA-Z0-9\\s.\\-]+$");

I hope this helps,


Reply With Quote

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Error in c# project: Unrecognized escape sequence Chris R. Timmons Microsoft Dot NET 2 12th Dec 2011 07:19 PM
RegEx and Vb.net /// "Unrecognized escape sequence" sloan Microsoft Dot NET Framework 4 27th Mar 2007 07:14 PM
RegEx and Vb.net /// "Unrecognized escape sequence" sloan Microsoft VB .NET 6 27th Mar 2007 06:12 PM
unrecognized escape sequence Abraham Luna Microsoft C# .NET 4 8th Sep 2005 06:44 PM
Unrecognized escape sequence Christopher Ireland Microsoft C# .NET 2 20th Sep 2004 07:50 AM




All times are GMT +1. The time now is 01:34 AM.