Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have string with is having the alpha numeric noted as below.

Ex 1: abc1232323acvc23232avac
Ex 2: abc1232bcsb

Here I want to check the string is alpha number as well as continuous numeric length should not exceed more than 7.


I have tried but I couldn't get the proper regular expression.

Kindly help me on this

What I have tried:

Tried with
(([a-z]+[0-9]+)+|(([0-9]+[a-z]+)+))[0-9a-z]{0.7}*
Posted
Updated 22-Aug-17 16:08pm
v2

1 solution

Your RegEx is weird, replace {0.7} with {0,7} to control repeat. The * at the end is an error too.
Use last link to see a nice diagram of your RegEx, it may help to anderstand what is wrong.

Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900