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
185 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

747 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

13 Experts available now in Live!

Get 1:1 Help Now