如何在'='后替换特定字符在notepad ++中的所有行中签名
How to replace a particular character after '=' sign in all the rows in notepad++
我的文件内容如下
abcd-12=jksjd-jkkj
xyzm-87=hjahf-tyewg-iuoiurew
zaqw-99=poiuy-12hd-jh-12-kjhk-4rt45
我想用下划线替换“=”后的连字符,即等式的 R.H.S。
No of hypenated terms are variable in the lines, it can be 3 or 4 or 5
如何对整个文档执行此操作。左侧应该完好无损。
我想要的结果是:
abcd-12=jksjd_jkkj
xyzm-87=hjahf_tyewg_iuoiurew
zaqw-99=poiuy_12hd_jh_12_kjhk_4rt45
一个选项是在正则表达式模式下进行以下查找和搜索:
Find: = ([^-]+)-([^-]+)$
Replace: = _
此处的策略是匹配并捕获出现在等式右侧的连字符项的两半。然后,替换为用下划线分隔的两半。
编辑:
如果 RHS 确实有 四个 个带连字符的术语,则使用:
Find: = ([^-]+)-([^-]+)-([^-]+)-([^-]+)$
Replace: = ___
搜索:
(=[^-\r\n]+)-
替换为:
_
注意:重复搜索和替换,直到没有更多的替换。
测试here.
这将在一次通过中替换任意数量的连字符:
- Ctrl+H
- 查找内容:
(?:=|(?!^)\G).*?\K-
- 替换为:
_
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
(?: # non capture group
= # equal sign
| # OR
(?!^) # negative lookahead, make sure we are not at the beginning of a line
\G # restart from last match position
) # end group
.*? # 0 or more any character but newline, not greedy
\K # forget all we have seen until this position
- # a hyphen
屏幕截图(之前):
屏幕截图(之后):
我的文件内容如下
abcd-12=jksjd-jkkj
xyzm-87=hjahf-tyewg-iuoiurew
zaqw-99=poiuy-12hd-jh-12-kjhk-4rt45
我想用下划线替换“=”后的连字符,即等式的 R.H.S。
No of hypenated terms are variable in the lines, it can be 3 or 4 or 5
如何对整个文档执行此操作。左侧应该完好无损。
我想要的结果是:
abcd-12=jksjd_jkkj
xyzm-87=hjahf_tyewg_iuoiurew
zaqw-99=poiuy_12hd_jh_12_kjhk_4rt45
一个选项是在正则表达式模式下进行以下查找和搜索:
Find: = ([^-]+)-([^-]+)$
Replace: = _
此处的策略是匹配并捕获出现在等式右侧的连字符项的两半。然后,替换为用下划线分隔的两半。
编辑:
如果 RHS 确实有 四个 个带连字符的术语,则使用:
Find: = ([^-]+)-([^-]+)-([^-]+)-([^-]+)$
Replace: = ___
搜索:
(=[^-\r\n]+)-
替换为:
_
注意:重复搜索和替换,直到没有更多的替换。
测试here.
这将在一次通过中替换任意数量的连字符:
- Ctrl+H
- 查找内容:
(?:=|(?!^)\G).*?\K-
- 替换为:
_
- 检查 环绕
- 检查 正则表达式
- 取消选中
. matches newline
- 全部替换
解释:
(?: # non capture group
= # equal sign
| # OR
(?!^) # negative lookahead, make sure we are not at the beginning of a line
\G # restart from last match position
) # end group
.*? # 0 or more any character but newline, not greedy
\K # forget all we have seen until this position
- # a hyphen
屏幕截图(之前):
屏幕截图(之后):