Home > Enterprise >  Is there a shorter version of a regex?
Is there a shorter version of a regex?

Time:11-27

I have these strings C910 C918 C920 C924 C925 C926 C928 C929 C930 C937 C940 C942 C943 C947 C950

and this regex works

^(C9[1-5]0|C9[12]8|C94[237]|C92[4569]|C937)$

but can it be made shorter and more elegant?

CodePudding user response:

Try this, bring C9 out as its common to all terms you require.

 ^(C9)([1-5]0|[12]8|4[237]|2[4569]|37)$
  • Related