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 ]
-