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 use sublime text to replace that with a /
If you could give a quick explanation that would help to
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With