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

How can I use the negation within square brackets as an exception, to find e. g. everything between a-z except for the the range from m-o? [a-z^m-o]?

By the way: it's not for the sake of this example that I ask, but to be able to exclude ranges within ranges, or even single letters within ranges. I am pretty much aware that in this example it can be calculated.

I use the Zend engine (PHP).

See Question&Answers more detail:os

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

1 Answer

You should be able calculate the difference yourself.

[a-lp-z]

If the regex engine supports lookahead assertion, you could use

(?![m-o])[a-z]

but this would probably be less efficient.


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