regex replacing at beginning of line in notepad++

后端 未结 2 688
误落风尘
误落风尘 2021-01-24 08:11

for example I have txt with content

qqqqaa
qqss
ss00

I want to replace only one q at the beginning of line, that is to get

qqq         


        
相关标签:
2条回答
  • 2021-01-24 08:33

    The issue is that Notepad++ Replace All functionality replaces in a loop using the modified document.

    The solution is to actually consume what we need to replace and keep within one regex expression like

    ^q(q*)
    

    and replace with $1.

    The pattern will find a q at the beginning of the line and then will capture into Group 1 zero or more occurrences of q after the first q, and in the replacement part the $1 will insert these qs inside Group 1 back into the string.

    0 讨论(0)
  • 2021-01-24 08:40

    You can use ^q(.+) and replace with $1 if you also want to replace single q's.

    0 讨论(0)
提交回复
热议问题