I'm trying to match the following possibilities with a regex:
MORE THAN CAD 10,000
MORE THAN CAD 10,000 BUT LESS THAN CAD 15,000
LESS THAN CAD 10,000
My regex works with /^(((MORE|LESS) THAN CAD [d,]+)|(MORE THAN CAD [d,]+ BUT LESS THAN CAD [d,]+))$/
but I'm wondering if there's a more elegant way.
I've tried /^(MORE THAN CAD [d,]+)?(( BUT )?LESS THAN CAD [d,]+)?$/
but it's letting the following pass as well:
MORE THAN CAD 10,000LESS THAN CAD 15,000
question from:
https://stackoverflow.com/questions/65832261/how-to-improve-the-regex 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…