英文:
Adding characters to the first of lines with 60 or more characters
问题
在超过60个字符的行的开头添加字符,您可以如何做到这一点?
我使用这个 (.{60})\s
进行搜索,但我不知道要放什么来替换。
英文:
I want to adding character to the first of lines with 60 or more characters, how can I do this?
I used this (.{60})\s
to search, but I don't know what to put in replace
答案1
得分: 0
You may want to use a capturing group starting at begin of a line. You'd go through following steps:
- Ctrl+H
- Find what:
(^.{60})
- Replace with:
added text\1
- Tick the Wrap around option
- Search mode: Regular expression
- Click on Replace All (at your own risk)
is resulting in:
The replacement addedtext\1
is beginning with some text and adds the text stored by the capturing group.
Some additional information about reinserting text matched by capturing groups in the replacement text:
The
\1
syntax for backreferences in the replacement text is borrowed from the syntax for backreferences in the regular expression.\1
through\9
are supported by the JGsoft applications, Delphi, Perl (though deprecated), Python, Ruby, PHP, R, Boost, and Tcl.
$1
through$99
for single-digit and double-digit backreferences are supported by the JGsoft applications, Delphi, .NET, Java, JavaScript, VBScript, PCRE2, PHP, Boost, std::regex, and XPath.
Quoted from: Numbered Backreferences
英文:
You may want to use a capturing group starting at begin of a line. You'd go through following steps:
- <kbd>Ctrl</kbd>+<kbd>H</kbd>
- Find what:
(^.{60})
- Replace with:
added text\1
- Tick the Wrap around option
- Search mode: Regular expression
- Click on <kbd>Replace All</kbd> (at your own risk)
is resulting in:
The replacement addedtext\1
is beginning with some text and adds the text stored by the capturing group.
Some additional information about reinserting text matched by capturing groups in the replacement text:
>The \1
syntax for backreferences in the replacement text is borrowed from the syntax for backreferences in the regular expression. \1
through \9
are supported by the JGsoft applications, Delphi, Perl (though deprecated), Python, Ruby, PHP, R, Boost, and Tcl.
>$1
through $99
for single-digit and double-digit backreferences are supported by the JGsoft applications, Delphi, .NET, Java, JavaScript, VBScript, PCRE2, PHP, Boost, std::regex, and XPath.
Quoted from: Numbered Backreferences
Notepad++ regular expressions use the Boost regular expression library v1.80 (as of NPP v8.4.7), which is based on PCRE (Perl Compatible Regular Expression) syntax.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论