473,385 Members | 1,593 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,385 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 2343
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.