I have a problem. In notepad++ When I to clear everything behind : in replacement, I did ^[^:]+: But the problem is that the format of lines is name1:name2:name3 And I would like to remove the name1: so I would just have name2:name3 Any ideas?
Asked
Active
Viewed 68 times
0
-
If you match `^[^:]+:` and replace with an empty string, the result is `name2:name3` See https://regex101.com/r/cysPNl/1 – The fourth bird Aug 28 '20 at 12:33
-
I have more than 1 line of it when i do that it and click replace all it will also remove name2: – OKO Aug 28 '20 at 12:34
-
Try excluding the newline as well `^[^:\r\n]+:` – The fourth bird Aug 28 '20 at 12:36
-
Nothing changes – OKO Aug 28 '20 at 12:37
-
Can you add a full example to the question and what the result should be? – The fourth bird Aug 28 '20 at 12:37
-
my lines look like name1:name2:name3 So i want to remove the name1: – OKO Aug 28 '20 at 12:39
-
You could check https://stackoverflow.com/questions/37217137/regex-remove-before-colon-notepad or https://superuser.com/questions/1420401/notepad-delete-until-colon-for-every-line-with-replace-all – The fourth bird Aug 28 '20 at 12:51
1 Answers
2
It seems it's a bug :( in Npp, use the following:
- Ctrl+H
- Find what:
^[^:\r\n]+:(.+)$
- Replace with:
$1
- CHECK Wrap around
- CHECK Regular expression
- UNCHECK
. matches newline
- Replace all
Explanation:
^ # beginning of line
[^:\r\n]+ # 1 or more not colon or linebreak
: # a colon
(.+) # group 1, 1 or more any character but newline
$ # end of line
Replacement:
$1 # content of group 1
Screenshot (before):
Screenshot (after):

Toto
- 89,455
- 62
- 89
- 125
-
1I experienced the same behavior (bug) on Notepad++ v7.5.8 and your solution works for me ++ – The fourth bird Aug 28 '20 at 17:26