How to match anything except space and new line?
python, regex
Solution
You can add the space character to your character class to be excluded.
^[^\n ]*$
Regular expression
^ # the beginning of the string
[^\n ]* # any character except: '\n' (newline), ' ' (0 or more times)
$ # before an optional \n, and the end of the string
Problem
I have a string, I just want to match substring for any character(s) except for space and new line. What should 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 it out how to club them together.