[SOLVED] Regex validation of two patterns multiple comma-separated doesn't work


In an ASP.NET form I am trying to find a pattern allowing multiple comma-separated elements but it doesn’t seem to work. I need to allow either 4 letters and 2 digits (JEAN01) or 2 digits and 4 letters (01JEAN) any number of times: JEAN01,JEAN02,03JEAN,JEAN04

My first attempt (see https://regex101.com/r/E4JZVv/1) is:


My second attempt (https://regex101.com/r/HU9cOS/1) is


The first accepts only a couple of elements.


That should do the trick:


See: https://regex101.com/r/8hoNXl/1


  • ^: Asserts position at start of the string
  • \w{4}\d{2}: 4 letters and 2 digits
  • \d{2}\w{4}: 2 digits and 4 letters
  • (,|$): Either , or the end of the string
  • +: Repeat between once and an unlimited number of times (greedy)

Answered By – Cubix48

Answer Checked By – Marilyn (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *