We help IT Professionals succeed at work.
Get Started

Regular Expression Alphanumeric String With Uppercase & Lowercase Characters

Last Modified: 2012-08-29
Hello,   I have been trying to create an alphanumeric RegEX expression which contains capital and lowercase letters but have been struggling to get it to work.
After looking at the following sites http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html    https://www.experts-exchange.com/Programming/Languages/Regular_Expressions/A_2140-Regular-Expressions-Starter-Guide.html
http://www.forcelabs.net/2011/07/regular-expression-to-validate-phone.html  I found the following


This I thought should check for alphanumeric with both capitals and smaller case letters but it does not.  it allows 'AA11111' for example to work. Also 'aa111111'.

Does anyone know how I can enforce the validation that both upper and lowercase characters are included in my string?

On a side note, For a separate check I could do with finding out if a string contains lowercase letters only (with no numbers).  Does anyone know the correct RegEx for this?

RegEx is confusing I have to say!!!!!!

Thanks in advance.
Watch Question
Most Valuable Expert 2011
Top Expert 2015
This problem has been solved!
Unlock 3 Answers and 26 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE