Notepad++ 记事本++;正则表达式删除标记内部/之间的空白,并按字母顺序排序

Notepad++ 记事本++;正则表达式删除标记内部/之间的空白,并按字母顺序排序,notepad++,Notepad++,我使用myinterest=“([^”]*)并替换为myinterest=“\L\1\text”使文本小写,并在后面添加“text”,但如何删除标记中不需要的空间?我尝试了\1,但没有工作 编辑:尝试“查找内容” (?:\bmyinterest=“|\G)\K\h*([^“\s>])+)(\h*”? “替换为” \L$1(?2文本): 这可以删除空格和小写字母,但我如何更改,使其按字母顺序排序?我尝试使用记事本+,但我不知道如何从myinterest=“”中的单词排序 示例数据: myinter

我使用myinterest=“([^”]*)并替换为myinterest=“\L\1\text”使文本小写,并在后面添加“text”,但如何删除标记中不需要的空间?我尝试了\1,但没有工作

编辑:尝试“查找内容” (?:\bmyinterest=“|\G)\K\h*([^“\s>])+)(\h*”? “替换为” \L$1(?2文本):

这可以删除空格和小写字母,但我如何更改,使其按字母顺序排序?我尝试使用记事本+,但我不知道如何从myinterest=“”中的单词排序

示例数据:

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag>
myinterest="horseridingtext">random Name</></endofothertag>
myinterest="bowlingtext">random Name</></endofothertag>
myinterest=“footballtext”>随机名称
myinterest=“sportsandflowerstext”>随机名称
myinterest=“horsridingtext”>随机名称
myinterest=“bowlingtext”>随机名称
应该是:

myinterest="bowlingtext">random Name</></endofothertag>
myinterest="footballtext">random Name</></endofothertag>
myinterest="horseridingtext">random Name</></endofothertag>
myinterest="sportsandflowerstext">random Name</></endofothertag>
myinterest=“bowlingtext”>随机名称
myinterest=“footballtext”>随机名称
myinterest=“horsridingtext”>随机名称
myinterest=“sportsandflowerstext”>随机名称

您没有提供示例数据,所以我临时准备了:

你可以试试这个

查找内容:
myinterest=“\s*([^”]*?)\s*”

替换为:
myinterest=“\L\1\Etext”

它将改变这一点:

myinterest="   Sports and Flowers   "
myinterest="Sports and Flowers"
myinterest="SPORT and wine"
myinterest=" TV "
myinterest="   MOVIES   "
myinterest=" food    "
myinterest="   running"
myinterest="play   "
。。。为此:

myinterest="sports and flowerstext"
myinterest="sports and flowerstext"
myinterest="sport and winetext"
myinterest="tvtext"
myinterest="moviestext"
myinterest="foodtext"
myinterest="runningtext"
myinterest="playtext"

您没有提供示例数据,因此我临时编制了:

你可以试试这个

查找内容:
myinterest=“\s*([^”]*?)\s*”

替换为:
myinterest=“\L\1\Etext”

它将改变这一点:

myinterest="   Sports and Flowers   "
myinterest="Sports and Flowers"
myinterest="SPORT and wine"
myinterest=" TV "
myinterest="   MOVIES   "
myinterest=" food    "
myinterest="   running"
myinterest="play   "
……在这方面:

myinterest="sports and flowerstext"
myinterest="sports and flowerstext"
myinterest="sport and winetext"
myinterest="tvtext"
myinterest="moviestext"
myinterest="foodtext"
myinterest="runningtext"
myinterest="playtext"
  • Ctrl+H
  • 查找内容:
    (?:\bmyinterest=“|\G)\K\h*([^”\s>]+)(\h*”?
  • 替换为:
    \L$1(?2text):
  • 检查环绕
  • 检查正则表达式
  • 全部替换
说明:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
更换:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
给定:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
myinterest=“足球”
myinterest=“体育与花卉”
myinterest=“football”>随机名称
myinterest=“运动与花卉”>随机名称
给定示例的结果:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
myinterest=“足球文本”
myinterest=“sportsandflowerstext”
myinterest=“footballtext”>随机名称
myinterest=“sportsandflowerstext”>随机名称
屏幕截图:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 

  • Ctrl+H
  • 查找内容:
    (?:\bmyinterest=“|\G)\K\h*([^”\s>]+)(\h*”?
  • 替换为:
    \L$1(?2text):
  • 检查环绕
  • 检查正则表达式
  • 全部替换
说明:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
更换:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
给定:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
myinterest=“足球”
myinterest=“体育与花卉”
myinterest=“football”>随机名称
myinterest=“运动与花卉”>随机名称
给定示例的结果:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 
myinterest=“足球文本”
myinterest=“sportsandflowerstext”
myinterest=“footballtext”>随机名称
myinterest=“sportsandflowerstext”>随机名称
屏幕截图:

(?:                 # non capture group
    \b              # word boundary
    myinterest="    # literally
  |                 # OR
    \G              # restart from last match position
)                   # end group
\K                  # forget all we have seen until this position
\h*                 # 0 or more horizontal spaces
([^"\s>]+)          # group 1, 1 or more non quote space or >
(\h*")?             # group 2, 0 or more horizontal spaces and a quote, optional
\L$1                # lowercase group 1
(?2                 # conditional replacement, if group 2 exists
    text"           # add text and quote
    :               # else, nothing
)                   # end condiitonal
myinterest="football"

myinterest="Sports and Flowers"

myinterest="football">random Name</></endofothertag> 
myinterest="Sports and Flowers">random Name</></endofothertag> 
myinterest="footballtext"

myinterest="sportsandflowerstext"

myinterest="footballtext">random Name</></endofothertag> 
myinterest="sportsandflowerstext">random Name</></endofothertag> 

您的问题非常不清楚,请添加示例文本和预期结果。记事本++不是满足您要求的工具,特别是排序。正则表达式是一种模式匹配。您可以将它与其他编程语言结合起来,做您想做的事。N++和Regex都不能单独完成。您的问题请添加示例文本和预期结果。Notepad++不是满足您的要求的工具,特别是排序。正则表达式是一种模式匹配,其他任何东西都不匹配。您可以将它与其他编程语言结合起来,做您想做的事。单靠N++或Regex都不能做到。谢谢,但它不起作用这是my示例数据和标记方式:实际上,我们的正则表达式似乎找到了这个myinterest=“fotball”>但不是这个:myinterest=“Sports and Flowers”>我现在将正则表达式更改为“lazy”,它应该匹配:myinterest=“Sports and Flowers”现在尝试了它,但没有删除单词之间的空白,例如myinterest=”sports and flowerstext“should chjange to myinterest=”sports and flowerstext“我意识到我应该在前面提到这一点:Dthanks但它不起作用这是我的示例数据,标签是什么:实际上,我们的正则表达式似乎找到了这个myinterest=”fotball“>但不是这个:myinterest=”sports and Flowers“>我将正则表达式改为“lazy”“现在,它应该匹配:myinterest=“Sports and Flowers”尝试了它,但没有删除单词之间的空白,例如myinterest=“Sports and flowerstext”应该更改为myinterest=“Sports and flowerstext”我意识到我应该在前面提到这一点:这很接近,但它也会更改其他标记中的文本,例如,这是完整字符串:myinterest=“football”>randonname您的正则表达式在randonname等中不断更改。它应该只更改这部分:myinterest=“football”myinterest=“Sports and Flowers”@Tim:不要给出示例我的评论,它是不可读的。正如我在上面的评论中所说的,并添加了一些测试用例。@Tim:只需在character类中添加
,请参阅我的编辑。谢谢,我忘了我还需要按字母顺序排列,请参阅我的更新question@Tim:如果所有行都以
myinterest=“blah blah”
开头,则可以安装插件TextFX,请参阅:此插件包含一个排序实用程序这很接近,但它也会更改其他标记中的文本,例如,这是完整字符串:myinterest=“football”>randomname您的正则表达式在randonname中不断更改,等等。它只应更改此部分:myinterest=“football”myinterest=“Sports and Flowers”@Tim:不要给出示例我的评论,这是不可读的。正如我在上面的评论中所说的,并添加了一些测试用例。@Tim:只需在character类中添加
,请参阅我的编辑。谢谢,我忘了我还需要按字母顺序排列,请参阅我的更新question@Tim:如果所有行都以
myinterest=“blah blah”
开头,则可以安装插件TextFX,请参阅:此插件包含排序实用程序