REGEX: Add something at the beginning of each line that does not contain the sign -
-
I want to add something to the beginning of each line that does not contain the sign
-
My regex is not so good:
FIND:
^(?!\-)
REPLACE BY:ANYTHING
-
Got it. There was no need for \ before -
FIND:
^(?!-)
REPLACE BY:ANYTHING
-
So for future people that come along looking maybe for a solution to something, and seeing this post, I say: It has several pieces of misinformation.
First, the “spec” was:
add something to the beginning of each line that does not contain the sign -
In fact, the regex supplied does not do this. What it does is: Add something to the beginning of each line that does not start with
-
.Second, the OP diagnosed a problem as being that:
There was no need for \ before -
In fact, the removal of
\
did nothing to change the outcome of the replacement operation.-
does not need to be “escaped” in the usage shown by the OP. While it was true that there was “no need”, it didn’t make the first regex not work. The two regexes supplied by the OP do exactly the same thing.