[英]Find and replace with regex in notepad++
I'm trying to remove lines that indicate page numbers from my document. 我正在尝试从文档中删除指示页码的行。
Rather than go through and manually remove each line, I wanted to do a find/replace with regex. 我想通过正则表达式来查找/替换而不是手动删除每行。
An example of an offending line is 违规行为的一个例子是
Page 62
第62章
I'm not having much luck with the regex. 我对正则表达式不太满意。
My regex is as follows 我的正则表达式如下
^Page [0-100]$
Scrolling to the bottom of the page, I can see that these lines end at Page 62
as per above, but this regex isn't finding any results. 滚动到页面底部,我可以看到这些行按上面的
Page 62
结束,但是此正则表达式未找到任何结果。
Can someone tell me what I did wrong? 有人可以告诉我我做错了什么吗?
EDIT 编辑
I've just tried matching ^Page \\d$
also with no results... 我刚刚尝试匹配
^Page \\d$
也没有结果...
[0-100]
is actually 0-1
, 0
, and 0
, not 0-100
. [0-100]
实际上是0-1
, 0
,和0
,而不是0-100
。 Therefore it will only match 0
or 1
. 因此,它将仅匹配
0
或1
。
Try this regex: 试试这个正则表达式:
^Page ([0-9][0-9])|(100)$
It will match Page
, then two digits or 100
. 它将匹配
Page
,然后匹配两位或100
。
If you don't care how big the page numbers can be, just use the "digit" escape sequence: 如果您不在乎页码可以有多大,请使用“数字”转义序列:
^Page \d+$
You could 你可以
^Page \d+\s*$
Page followed by 1 or more digit followed by any whitespace 页面后跟1个或多个数字,后跟任意空格
Your regex isn't valid. 您的正则表达式无效。 You can't match a number range that way.
您无法以这种方式匹配数字范围。 You have to check each digit.
您必须检查每个数字。
这个怎么样?
^Page [[:digit:]]+$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.