[英]NOTEPAD++ REGEX How do I replace and remove a whitespace from $0
I'm using this regex: 我正在使用此正则表达式:
\s[0-9]+ thd
It finds what I want perfectly. 它找到我想要的东西。 I want to remove the white space at the beginning.
我想在一开始删除空白。 What should I put in the replace field?
我应该在替换字段中输入什么?
将搜索文本更改为\\s([0-9]+ thd)
,然后根据正则表达式的类型将替换ID更改为\\1
或$1
。
Find: 找:
\s([0-9]+ thd)
Replace: 更换:
$1
So if you using Notepad++ everything in parenthesis refers to section build from \\
and number
in Replace box. 所以,如果你在括号中使用记事本++一切都指的是部分从建立
\\
和number
在替换框中。 Look at example: 看例子:
Find: (\s)([0-9]+ thd)
Replace: \1\2
This give you back first \\1
and second \\2
section - nothing unusual, but when you live only \\2
after replace you'll get only part found by ([0-9]+ thd)
这使您返回第一
\\1
和第二\\2
部分-没什么异常,但是当替换后仅居住\\2
,您只会得到([0-9]+ thd)
Going further if you split your expression to (\\s)([0-9]+)(\\s)(thd)
then you'll get 4 parts 如果将表达式拆分为
(\\s)([0-9]+)(\\s)(thd)
则可以得到4个部分
This parts will be represented by \\1\\2\\3\\4
and if you need add something more to your output line: 这部分将由
\\1\\2\\3\\4
,如果需要在输出行中添加更多内容:
for example added_text_before\\1added_text_after
in Replace will result merging added text and section found - practice because there is no hidden magic out there. 例如,“替换”中的
added_text_before\\1added_text_after
将导致合并添加的文本和找到的部分-练习,因为那里没有隐藏的魔术。
Remember that using regex in Notepad++ have some limitations (to long expression aren't read). 请记住,在Notepad ++中使用正则表达式有一些限制(不读取长表达式)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.