tags:

views:

95

answers:

2

Please provide a solution to write a regular expression as following in C#.NET: I would require a RegEx as below:

Non-Alphabets(a to z;A to Z) and Non-Numerals(0 to 9) and also non-DOT (.). Mean to say as otherthan the mentioned above i want to handle reverse way for getting regular expression as other than alphabets, otherthan numerals(0 to 9) otherthan DOT(.).

Kindly suggest the solution for the same.

The Regex: [^a-zA-Z0-9] fails when i use DOT(.) in a string such as 'Test.01'

+3  A: 

[^a-zA-Z0-9.]

Dave DeLong
period is not a special character inside a character class - `[^a-zA-Z0-9.]` would suffice
Amarghosh
@Amarghosh ack! thanks for pointing that out. =)
Dave DeLong
I got a compiler error for \. too - unrecognised escape sequence
Jon
@Jon: That's probably because you forgot to prefix your regex string with `@` to make it a verbatim literal.
LukeH
+2  A: 

See related (almost dup) regex for non alphabets and non numerals

Chen Levy