Reputation: 18097
How do i write regex so it matches A-Z but not characters b,h,i. Only way i could think of is by using custom ranges.
/[[A][C-G][J-Z]]/gi
This is what i can think of, i don't think this is correct regex, even. i'd like to not write custom ranges if possible. As it's complicate things a lot more.
What i'm trying to do is make characters increase by one so a becomes b, c -> d, z -> a. Except some words. And this is my strategy... find all words except them, run them through match string and replace them with character that is one ahead using charcode.
Upvotes: 2
Views: 3489
Reputation: 784998
One way is to use negative lookahead:
/(?![BHI])[A-Z]/i
This will match anything in range [A-Z]
except characters B
, H
and I
.
Upvotes: 8