473,544 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex Error - unrecognized escape sequence

PK9
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 "unrecogniz ed 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(txt UVNONumber.Text ))
{
lblErrorMessage .Text = "Invalid entry for UVNO Number";
lblErrorMessage .Visible = true;
}
--
PK9
Jul 21 '05 #1
1 8265
PK9

Did you try this already

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

I hope this helps,

Cor
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2971
by: Johnny | last post by:
I need to determine whether a text box contains a value that does not convert to a decimal. If the value does not convert to a decimal, I want to throw a MessageBox to have the user correct the value in the text box. I have the following code but when the user enters a decimal value the Regex.IsMatch catches it (ex. 250.50 should be allowed,...
3
401
by: UK | last post by:
I'm looking for a pattern, for replacing whole words as long as they are not preceded by "#(" ==> where # stands for any number eg: (P is to be replaced with "ReplaceText") Input: AVG(P/123(P)*PE/P+213(P)) Output: AVG(ReplaceText/123(P)*PE/ReplaceText+213(P)) Thanks, UK.
1
726
by: PK9 | last post by:
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...
8
1951
by: mohit | last post by:
Hi, I am creating a web application in Web Matrix on the .NET framework. I have two directories :AddUser and FormAuth in a Directory P. AddUser contains a file AddUser.aspx FormAuth contains : Default.aspx , Users.xml , Login.aspx I have the following code :
11
3080
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend a hand? import regsub
1
3982
by: Dan Holmes | last post by:
i have this: new System.Text.RegularExpressions.Regex("^\d+$") // \d by itself failed as well. but the compiler generates "unrecognized escape sequence". so i changed it to this: new System.Text.RegularExpressions.Regex("^+$") and it worked fine.
6
6281
by: sloan | last post by:
I have a fairly simple RegEx code below. I am given a file name, (which I don't control) , and need to change a folder name in it. The code below is choking on the filename not being escaped. "Unrecognized escape sequence"
2
1476
by: nuffnough | last post by:
I am doing a string.replace in a simple table generation app I wrote, and I can't figure out how to match whitespace with /s, so I thought I would see if osmeone where would be kind enough to tell me what I am getting wrong. This works: string = string.replace('<tr>\n <th class="table">Field One</th> \n ...
3
14163
by: chemicalcold0 | last post by:
Hi there, since < has a meaning in c# for regular expressions and \< says it's an unrecognized escape sequence, I'm pretty lost parsing html tags without replacing them first with another character or string. Does anyone have a hint for me on how to get c# Regex class to find "<"? Thanks in advance,
0
7368
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7777
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7384
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5916
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1844
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.