character-class

Why doesn't this pattern work in egrep?

Why can't I match the string "1234567-1234567890" with the given regular expression \d{7}-\d{10} with egrep from the shell like this: egrep \d{7}-\d{10} file ? ...

Character class subtraction, converting from Java syntax to RegexBuddy

Which regular expression engine does Java uses? In a tool like RegexBuddy if I use [a-z&&[^bc]] that expression in Java is good but in RegexBuddy it has not been understood. In fact it reports: Match a single character present in the list below [a-z&&[^bc] A character in the range between a and z : a-z One of the cha...

Question about regular expressions

Hello all, I saw this statement $name = ereg_replace("[^A-Za-z0-9.]", "", $name); What is the difference between [^A-Za-z0-9.] and [A-Za-z0-9.]? Based on my understanding of regular expression, the [] is used to include all valid characters for replacment in function ereg_replace. Then what is the purpose of including ^ into the []...

How can I exclude some characters from a class?

Say I want to match a "word" character (\w), but exclude "_", or match a whitespace character (\s), but exclude "\t". How can I do this? ...

Replace all characters not in range (Java String)

How do you replace all of the characters in a string that do not fit a criteria. I'm having trouble specifically with the NOT operator. Specifically, I'm trying to remove all characters that are not a digit, I've tried this so far: String number = "703-463-9281"; String number2 = number.replaceAll("[0-9]!", ""); // produces: "703-46...