What characters are removed in thissimple regular expression

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

string s = Regex.Replace(input, @"[^\w\.@-]", "");
It's somewhat hard to see but there is a dot before @

What characters are removed from the input string ?
//Tony
 
Tony said:
Hi!

string s = Regex.Replace(input, @"[^\w\.@-]", "");
It's somewhat hard to see but there is a dot before @

What characters are removed from the input string ?
//Tony
Anything that isn't a word character, a period, an @ sign, or a hyphen.
 
string s = Regex.Replace(input, @"[^\w\.@-]", "");
It's somewhat hard to see but there is a dot before @

What characters are removed from the input string ?

This is simply a matter of reading the regex.

If you don't know regex then find one of the online
tutorials like:
http://www.regular-expressions.info/tutorial.html

For a quick ref card I like the Java docs:
http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html

(Java and .NET are relative compatible regarding regex syntax)

Arne
 
Back
Top