• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 51
  • Last Modified:

Help with RegEx

I need a pattern string to edit a 10-character field having its first two characters equal to 'AA', 'AB' or 'AC', and the remaining eight characters numeric.  I don't know the RegEx "language", and don't know where to start.  Can anyone help?
2 Solutions
Bill PrewCommented:
I would use the following:


Open in new window

Tested here:


or simply

Open in new window

Radek BaranowskiFull-stack Java DeveloperCommented:
[ABC]{2}[0-9]{8} would be the simplest I guess.

future reference: https://regexr.com/
Bill PrewCommented:
Just to inform my solution, I assumed that AA, AB, and AC were just examples, and that the real world case would be a number of combinations of two characters...

Also make sure you start and end the pattern with ^ and $ respectively, so that things like "XXAB00000000" or "AB000000000" don't pass.  Unless the input field involved is limited to 10 characters on input by the UI...

petekipeOwnerAuthor Commented:
Thanks for your help on this Bill!
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now