Solved

I am adding regular expressions dynamically. I have to write the validation expression in code behind. But when i add the expression, it says, invalid escape sequence. What can i do??

Posted on 2009-04-03
6
186 Views
Last Modified: 2012-05-06
I am adding regular expressions dynamically. I have to write the validation expression in code behind. But when i add the expression, it says, invalid escape sequence. What can i do??
0
Comment
Question by:pinky1307
  • 4
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 24057429
what expression do you write?
0
 

Author Comment

by:pinky1307
ID: 24057435
"^[+-]?\d+(\.\d+)?$"
0
 

Author Comment

by:pinky1307
ID: 24057438
Thanks for the reply. for integer or float values and for integer or decimal values. it takes "." and "\" as escape sequences
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:pinky1307
ID: 24057447
RegularExpressionValidator rv = new RegularExpressionValidator();
                                rv.ID = rev;
                                rv.ControlToValidate = tb.ID;
                                rv.ErrorMessage = "Must be an integer ";
                                rv.Text = "*";
                                rv.ValidationExpression = ("^[+-]?\d+(\.\d+)?$");

this is the code i use.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 24057556
you may need to use "\\" to pass a literal \ in ""
0
 

Author Comment

by:pinky1307
ID: 24057564
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now