DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: ASP.net and regular expression

  1. #1
    Join Date
    Jul 2007
    Posts
    5

    ASP.net and regular expression

    Ok this probably has a really simple answer but i am new to asp.net and for some reason i just cant figure it out.

    I have a text field that currently has a validator on it which has a regular expression attached to it.

    my regular expression is as follows ^[a-zA-Z\d\s,.?!'@]+$ now i want to edit this so it can accept double quotes however as the reg ex is stored in a string ("^[a-zA-Z\d\s,.?!'@]+$") when i add the double quote into the reg ex it ends the string, i have tried escaping it with \ which doesn't work, is there a different escape character for asp.net? or am i just being stupid and missing something really obvious?

    any help is welcomed

    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Assuming you're using VB (in C#, escaping with \ should work), you can do this:

    Pattern = "^[a-zA-Z\d\s,.?!'@" & Chr(34) & "]+$"

    Or you can do this:

    Pattern = "^[a-zA-Z\d\s,.?!'@\x22]+$"
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jul 2007
    Posts
    5
    Thread is accessible again now

    I am using c# and the \ does not seem to work i have also tried it as its own escape char no no avail any other advice?
    Last edited by -zorro-; 07-13-2007 at 07:19 PM.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try \x22
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Jul 2007
    Posts
    5
    Thanks for your help that seems to work

Similar Threads

  1. regular expression
    By elmasduro in forum Database
    Replies: 0
    Last Post: 03-29-2007, 02:49 PM
  2. Regular Expression Performance
    By Massif in forum Java
    Replies: 0
    Last Post: 07-19-2006, 04:42 PM
  3. Convert String to Regular Expression
    By alexl22 in forum Java
    Replies: 1
    Last Post: 11-18-2005, 11:26 AM
  4. Replies: 2
    Last Post: 09-29-2005, 02:09 AM
  5. regular expression
    By Claudiu in forum Database
    Replies: 1
    Last Post: 02-05-2003, 08:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center