Javascript Regular expression

I need 2 javascript regular expressions one where        GEI/any 3 alphabets/any 9 digits

second where                           first three alphabets should not be GEI/any 3 alphabets/any 9 digits
Who is Participating?
Rainer JeschorConnect With a Mentor Commented:
perhaps this helps:
var pattern1 = /(GEI)\/[A-z]{3}\/\d{9}/g;
var pattern2 = /(?!GEI)...\/[a-z,A-Z]{3}\/\d{9}/g;

Open in new window

see here:

Could you create a well formatted question? Thanks.
Terry WoodsConnect With a Mentor IT GuruCommented:
@RainerJ's first pattern may cause problems if you use [A-z], as other characters (non-alpha) may occur between the ASCII codes for A and z. It also needs a start and end-of-string placeholder (^ and $) to ensure other characters aren't included at either end. It should be:

var pattern1 = /^(GEI)\/[a-zA-Z]{3}\/\d{9}$/g;

Open in new window

The second pattern should have the , removed, and ^ and $ added, so:
var pattern2 = /^(?!GEI)...\/[a-zA-Z]{3}\/\d{9}$/g;

Open in new window

ps: Please split the points with @RainerJ if you accept my answer...
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

ok guys, going to buy a new set of glasses...
Terry WoodsConnect With a Mentor IT GuruCommented:
Rereading the question, I wonder if the 2nd pattern should be this:

var pattern2 = /^(?!GEI)[a-zA-Z]{3}\/[a-zA-Z]{3}\/\d{9}$/g;

Open in new window

That means you're wanting 2 groups of 3 alpha characters, separated by /, as long as the first 3 aren't GEI.
RobOwner (Aidellio)Commented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Terry WoodsIT GuruCommented:
In this case, I believe my answer was correct and deserves some points.

I recommend a split with @RainerJ's answer #39477889 (50%), and mine: #3947818 (25%), and #39478250 (25%).

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.