Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to write a regular expression matching a set without some chars.

For example, it matches [ a-zA-Z]* but excludes i,o,q,I,O,Q.

So: "A fat cat" matches, "Boy" doesn't.

Looks like it can be [ a-hj-npr-zA-HJ-NPR-Z]*.

Is there a simpler version for this?

Btw, I'm using it in PostgreSQL, but I think it should be a standard expression.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
183 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use negative lookahead for this as Postgresql support lookaheads:

(?![ioqIOQ])[A-Za-z ]

To make it match complete line use:

^(?:(?![ioqIOQ])[A-Za-z ])+$

RegEx Demo


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...