【问题标题】:How to replace `abc` to `abc'` in Notepad++ using Regex如何使用正则表达式在 Notepad++ 中将 `abc` 替换为 `abc'`
【发布时间】:2016-08-09 15:21:42
【问题描述】:

原文:

set    ,     1
note   ,     1
hello  ,     1

预期文本:

set'    ,     1
note'   ,     1
hello'  ,     1

我尝试将[a-z]\s 替换为',但它会丢失最后一个字符。

【问题讨论】:

  • (?<=[a-z])\s notepad++ 是否支持positive lookbehind

标签: regex text replace notepad++ text-editor


【解决方案1】:

试试这个

([a-z])\s

Regex demo

替换: $1'

【讨论】:

    【解决方案2】:

    [a-z] 表示az 范围内的一个字符,您必须使用[a-z]++ 表示一个或多个字符。

    我建议你使用:

    ^([a-z]+)
    

    在替换字段中,写:

    $1'
    

    ^ 表示字符串的开头。 $1 是一个变量,您将匹配的字符串存储在括号 () 内。

    【讨论】:

    • 我同意你的看法。还是有问题要换。如何保留原来的匹配字符?
    • 我更新了答案。抱歉之前的不完整
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多