Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > regular expression for case insensitive USA state codes

Reply
Thread Tools

regular expression for case insensitive USA state codes

 
 
Stan
Guest
Posts: n/a
 
      05-16-2006

I have a very simple web form with a textbox and a regular expression
validator. The regular expression I'm attempting to use doesn't work on the
client side (Javascript) tho it works on the server side.

Anyone have an idea of how to make this following regex work on the client
side and case insensitive?

The following works for CAPITALIZED letters (but I don't want the user to
be forced into entering caps or do any Javascript tricks to capitalize when
the user types.)

MyRegex.ValidationExpression = "^(A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[ANU]
|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]
|UT|V[AIT]|W[AIVY])$"

A user in another Forum gave me this regular expression below, but it
doesn't seem to work irregardless of the case.

MyRegex.ValidationExpression = "/^(A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[ANU]
|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]
|UT|V[AIT]|W[AIVY])$/i"


Thanks in advance,
Stan
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      05-16-2006
Add this to the beginning: (?i)

This is an instruction to the regular expression to ignore case.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Stan" <(E-Mail Removed)> wrote in message
news:Xns97C5A28524586aw3er4fresagss@69.28.186.121. ..
>
> I have a very simple web form with a textbox and a regular expression
> validator. The regular expression I'm attempting to use doesn't work on
> the
> client side (Javascript) tho it works on the server side.
>
> Anyone have an idea of how to make this following regex work on the client
> side and case insensitive?
>
> The following works for CAPITALIZED letters (but I don't want the user to
> be forced into entering caps or do any Javascript tricks to capitalize
> when
> the user types.)
>
> MyRegex.ValidationExpression = "^(A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[ANU]
> |HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]
> |UT|V[AIT]|W[AIVY])$"
>
> A user in another Forum gave me this regular expression below, but it
> doesn't seem to work irregardless of the case.
>
> MyRegex.ValidationExpression = "/^(A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[ANU]
> |HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]
> |UT|V[AIT]|W[AIVY])$/i"
>
>
> Thanks in advance,
> Stan



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
check file exists with case sensitive on a case insensitive filesystem Xah Lee Perl Misc 4 04-05-2009 11:21 PM
case insensitive find on case sensitive stl map benhoefer@gmail.com C++ 1 04-06-2007 08:42 PM
Virtual Key Codes, Scan Codes and ASCII Codes in C gj_williams2000@yahoo.co.uk C Programming 2 08-20-2005 11:04 AM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM



Advertisments