How to replace a character without affecting the other character with notepad?
-
Friends I have this problem, I need to replace the character: without affecting the other character like the previous one (:), for example
ame: 1234: test
journal:gift:5ty
to
ame1234: test
journalgift:5typlease
-
Seems like you need to delete the first, and only the first.
:on a line. Is that right? What if a line only has one:…does it still get removed? -
I need to eliminate the first one:
They are more than 10000 lines, and they all have the:, as well as the example -
Try this:
Find what zone:
^([^:\r\n]*):
Replace with zone:\1
Wrap around checkbox: as you like it
Search mode: Regular expression
Action: Press Replace / Replace All buttonHere’s an explanation of how it works:
THE FIND EXPRESSION:
^([^:\r\n]*):- [Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed)][1 ]
^ - [Match the regex below and capture its match into backreference number 1][2 ]
([^:\r\n]*)- [Match any single character NOT present in the list below][3 ]
[^:\r\n]*- [Between zero and unlimited times, as many times as possible, giving back as needed (greedy)][4 ]
* - [The colon character][5 ]
: - [The carriage return character][6 ]
\r - [The line feed character][6 ]
\n
- [Between zero and unlimited times, as many times as possible, giving back as needed (greedy)][4 ]
- [Match any single character NOT present in the list below][3 ]
- [Match the colon character][5 ]
:
THE REPLACE EXPRESSION:
\1- [Insert the text that was last matched by capturing group number 1][7 ]
\1
Created with RegexBuddy
[1 ]: http://www.regular-expressions.info/anchors.html
[2 ]: http://www.regular-expressions.info/brackets.html
[3 ]: http://www.regular-expressions.info/charclass.html
[4 ]: http://www.regular-expressions.info/repeat.html
[5 ]: http://www.regular-expressions.info/characters.html
[6 ]: http://www.regular-expressions.info/characters.html#special
[7 ]: http://www.regular-expressions.info/replacebackref.html - [Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed)][1 ]
-
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