CharlieNoodles
CharlieNoodles

Reputation: 356

Regular expression Javascript match letters except one

I am trying to improve my regular expression in order to not match this string when it has a D in it:

www.google.com/.../DE69619938D1?cl=e

My regex :

(DE)([0-9]{1,12})((?:[ABCUT][0-9]?)?)
  1. I want to match when "D1" is missing: that's why I put a ? after this group. (working)
  2. I want to match when the letter is A B C U or T. (working)
  3. But when it is a D after the numbers I don't want to match the string and I don't know how to make this without losing the first rule.

Upvotes: 0

Views: 112

Answers (1)

dencey
dencey

Reputation: 1061

Try this

(DE)([0-9]{1,12})(?:(?:[ABCUT][0-9]?)|\?)

Upvotes: 2

Related Questions