Regular expression: find spaces (tabs/space), but not newlines

Viewed 236189

How can I have a regular expression that tests for spaces or tabs, but not newlines?

I tried \s, but I found out that it tests for newlines too.

I use C# (.NET) and WPF, but it shouldn't matter.

5 Answers

If you want to replace space, the below code worked for me in C#.

Regex.Replace(Line, "\\\s", "");

For Tab

Regex.Replace(Line, "\\\s\\\s", "");
Related