tags:

views:

53

answers:

2

Hi ! Let say I have set of characters [a-z] I want to match every character from the set, except character "a" Thanks !

+3  A: 

You can specify the character ranges as you want, for example:

[b-z]

This will only match the character from b to z. The only restriction is that it’s a valid character range according to the character set that is used so that the first character has a lower code point than the second character.

Gumbo
Hi ! I figured that [b-z] is simplest solution. But what if I would want something in the middle of alphabet ? [a-df-z] for letter except "e". I am looking for something direct.
@user465292: That is the most comprehensive way. Another way would be to use [look-around assertions](http://www.regular-expressions.info/lookaround.html), e.g. `(?!e)[a-z]` (look-ahead) or `[a-z](?<!e)` (look-behind). But those are not supported by every regular expression library.
Gumbo
A: 
[a-z-[e]]

means "any character between a and z except e". But as far as I know, only .NET, JGSoft and XML Schema support these "subtracted character classes".

Another example:

[a-z-[aeiou]]

matches any (ASCII) consonant.

Tim Pietzcker
In Java, those would be `[a-z
Alan Moore