记事本++中的正则表达式在随机数末尾添加文本

记事本++中的正则表达式在随机数末尾添加文本
Book 28, Number 3846:
we can go to school today
Book 27, Number 3847:
he is very sick
Book 28, Number 3848:
today is holday
Book 22, Number 3849:
hello my name is abc
Book 28, Number 3850:
thank you dear
Book 28, Number 3851:
what is your name

如何使用记事本中的 RegEx 在书籍行中添加一些文本?

书号是随机的,同样数字后面的值也是随机的。我想让它们像这样。

 Book 28, Number 3846: ###
we can go to school today
 Book 28, Number 3847: ###
he is very sick
 Book 28, Number 3848: ###
today is holday
 Book 28, Number 3849: ###
hello my name is abc
 Book 28, Number 3850: ###
thank you dear
 Book 28, Number 3851: ###
what is your name

答案1

假设所有需要附加文本的行都以 Book 开头,而其他行不以 Book 开头,则可以使用以下正则表达式:

搜索: (^Book \d.+$) 替换为: $1 ###

解释:

(              )   = Capture group. Everything it finds is stored as $1
 ^                 = This must occur at the start of the line.
  Book             = Match the word Book, followed by a space
       \d          = The next character(s) must be a digit.
          .+       = The next characters must be anything
             $     = Until the end of the line is reached.

通过用 $1 替换您的文本,相同的文本将附加到以书号开头的每一行。

相关内容