473,287 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

regular expression for case insensitive USA state codes


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
May 16 '06 #1
1 2341
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" <no*******@mail.com> wrote in message
news:Xn****************************@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

May 16 '06 #2

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

Similar topics

9
by: Harry | last post by:
Hi there, does anyone know how I can build a regular expression e.g. for the string.search() function on runtime, depending on the content of variables? Should be something like this: var...
5
by: Amy L. | last post by:
I was looking at some Regular Expressions and I noticed some of them have the following character in them "/i". For example: \b(?:college|university)\s+diplomas/i In the .Net documents I can't...
8
by: Rajeev Soni | last post by:
Hi I am looking for the regular expression for validating the allowed file types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the expression should not be case sensitive like...
7
by: Chris Kennedy | last post by:
Does anyone know a regular expression that will validate the file extension but also allow multiple file extensions if necessary. It also needs to be case insensitive. Basically, what I want is to...
5
by: John | last post by:
I am new in Regular Expression. Could someone please help me in following expression? 1. the string cannot be empty 2. the string can only contains AlphaNumeric characters. No space or any...
14
by: olekristianvillabo | last post by:
I have a regular expression that is approximately 100k bytes. (It is basically a list of all known norwegian postal numbers and the corresponding place with | in between. I know this is not the...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
3
by: shapper | last post by:
Hello, I have a regular expression to validate email addresses: "\w+(\w+)*@\w+(\w+)*\.\w+(\w+)*" Now I need to force all emails to be from a given domain, for example, accept only:...
6
by: David | last post by:
I'm having trouble getting the regular expression validator to work with a text box. In this simple example I only want lower case letters to be allowed. So I tried the following and it doesn't...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.