So regular expressions have always been tough for me. Im getting frustrated trying to find a regular expression that will select the first white space on a line. So then i can u
In the spirit of @edi's answer, but with some explanation of what's happening. Match the beginning of the line with ^
, then look for a sequence of characters that are not whitespace with [^\s]*
or \S*
(the former may work in more editors, libraries, etc than the latter), then find the first whitespace character with \s
. Putting these together, you have
^[^\s]*\s
You may want to group the non-whitespace and whitespace parts, so you can do the replacement you're talking about:
^([^\s]*)(\s)
Then the replacement pattern is just \1/