将节点名称 XML 替换为正则表达式 Notepad++
Replace node name XML with regular expresión Notepad++
已编辑
我正在尝试在 Notepad++ 上用正则表达式替换节点名称。我有类似的东西:
<Vehicle_name color="green" type="sub" extra="panoramic roof">
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle>
<Vehicle_brand color="green" type="sub" extra="panoramic roof">
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle>
我想得到这个
<Vehicle_name color="green" type="sub" extra="panoramic roof">
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle_name>
<Vehicle_brand color="green" type="sub" extra="panoramic roof">
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle_brand>
特纳克斯
- Ctrl+H
- 查找内容:
<Vehicle(_\w+).+?</Vehicle\K>
- 替换为:
>
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 检查
. matches newline
- 全部替换
解释:
<Vehicle # literally
(_\w+) # group 1, 1 or more word character
.+? # 1 or more any character, not greedy
</Vehicle # literally
\K # forget all we have seen until this position
> # >
替换:
# content of group 1
> # >
截图(之前):
截图(后):
已编辑
我正在尝试在 Notepad++ 上用正则表达式替换节点名称。我有类似的东西:
<Vehicle_name color="green" type="sub" extra="panoramic roof">
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle>
<Vehicle_brand color="green" type="sub" extra="panoramic roof">
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle>
我想得到这个
<Vehicle_name color="green" type="sub" extra="panoramic roof">
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
<InvoiceDateTime InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle_name>
<Vehicle_brand color="green" type="sub" extra="panoramic roof">
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
<AuthorizationCode InvoiceChargeCents="63" OptionCode="nothing"/>
</Vehicle_brand>
特纳克斯
- Ctrl+H
- 查找内容:
<Vehicle(_\w+).+?</Vehicle\K>
- 替换为:
>
- 检查 匹配大小写
- 检查 环绕
- 检查 正则表达式
- 检查
. matches newline
- 全部替换
解释:
<Vehicle # literally
(_\w+) # group 1, 1 or more word character
.+? # 1 or more any character, not greedy
</Vehicle # literally
\K # forget all we have seen until this position
> # >
替换:
# content of group 1
> # >
截图(之前):
截图(后):