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!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login