Skip to content
Advertisement

How to matches anything except space and new line?

I have a string, I just want to match string for any character except for space and new line. What must be regular expression for this?

I know regular expressions for anything but space i.e. [^ ]+ and regular expression for anything but new line [^n]+ (I’m on Windows). I am not able to figure how to club them together.

Advertisement

Answer

You can add the space character to your character class to be excluded.

JavaScript

Regular expression

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement