【问题标题】:Modify capitalisation and add numbers to mass lines of text修改大小写并向大量文本行添加数字
【发布时间】:2017-09-22 13:56:11
【问题描述】:

假设我有成百上千行这样的文本:

yes:nice
up:true
six:hello
nine:mouse
twenty:cat

我希望它能够做到这一点:

yes:Nice1
up:True1
six:Hello1
nine:Mouse1
twenty:Cat1

因此,每一行都有一侧带有文本/数字,而冒号 (:) 将另一侧与更多文本/数字分开。

有没有办法批量修改每一行以使冒号后的起始字符 (:) 大写?

我还想知道如何在每一行的末尾添加任何数字。

基本上我想知道如何在冒号后更改字符的大小写以及如何在末尾添加我想要的任何数字。

【问题讨论】:

    标签: text notepad++ text-editor editing modifier


    【解决方案1】:

    这是完成这项工作的一种方法:

    • Ctrl+H
    • 查找内容:^([^:]+:)(.)(.*)$
    • 替换为:$1\U$2\E${3}1
    • 全部替换

    说明:

    ^               : begining of line
      ([^:]+:)      : group 1, every thing before the colon & the colon
      (.)           : group 2, 1 character
      (.*)          : group 3, every thing after the first character
    $
    

    替换:

    $1              : group 1
    \U$2\E          : group 2, uppercase
    ${3}            : group 3
    1               : the digit 1, or anything you want to append.
    

    给定示例的结果:

    yes:Nice1
    up:True1
    six:Hello1
    nine:Mouse1
    twenty:Cat1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-20
      • 2019-07-27
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      相关资源
      最近更新 更多