Search code examples
regexnotepad++

first match every line regex notepad++


i have a bulk process to do this using notepad++ regex

abcd:1234:12342:13234

abcde:123431:1234123:1234

abcdqsd:1231234:1234123:1234

abcdzza:121234:1234123:1234

abcdzzs:1234231:2311234:1234

i need to remove first match separated by : delimiter every line

list becomes

1234:12342:13234

123431:1234123:1234

1231234:1234123:1234

121234:1234123:1234

1234231:2311234:1234

i ve tried

.*:

but it selects 2 first matches


Solution

  • Your .*: matches zero or more characters other than a newline (without DOTALL modifier) up to the last occurrence of : on a line.

    You can use the following regex:

    ^[^:\n\r]*:(.*)
    

    and replace with $1.

    Explanation:

    • ^ - start of line
    • [^:\n\r]* - zero or more characters other than : and linebreaks
    • : a literal :
    • (.*) - Group 1: all the rest of the line that will backreference with $1 in the replacement pattern (since we want to keep it).

    enter image description here