Balaji M
Balaji M

Reputation: 127

regex matches \n in c#

i need to escape the special characters, so i have checked the regex options like as below, new Regex(@"^[\[email protected]]*$",RegexOptions.Compiled); it's working fine for all special character except \n so how can i check it for all special character.

Upvotes: 1

Views: 85

Answers (1)

James Buck
James Buck

Reputation: 1640

Use a negative lookahead assertion:

^[\[email protected]]*(?!\n)$

Demo.

Upvotes: 2

Related Questions