在具有60个或更多字符的第一行中添加字符

huangapple go评论55阅读模式
英文:

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:

在具有60个或更多字符的第一行中添加字符

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:

在具有60个或更多字符的第一行中添加字符

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.

huangapple
  • 本文由 发表于 2023年5月14日 07:35:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245266.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定