I need to insert a special character at the beginning of a line
-
In a simple text file, I have the following lines:
#–output blah blah 1
#–output blah blah 2
#–output blah blah 3
–output blah blah 4
#–output blah blah 5I need to insert the hashtag symbol inserted at the beginning of line # 4 – but ONLY for those lines that does not start with #.
If I do a simple find & replace operation on the two hyphens like this:
find: –
replace with: #–I get the following result which is not want I want.
##–output blah blah 1
##–output blah blah 2
##–output blah blah 3
#–output blah blah 4
##–output blah blah 5Is there a RegEx solution for this?
-
@JustinJudo said in I need to insert a special character at the beginning of a line:
Is there a RegEx solution for this?
Yes.
FIND =
^(?!#)
REPLACE =#
-> from the beginning of line, where the next character is not a hashtag, replace the beginning of the line with a hashtag
----
Useful References
-
@PeterJones Thank you Peter, I appreciate the solution. Man you’re so good with this stuff… I wish I knew how to do RegEx. I’ve looked it before but it just seem so difficult to learn!