0

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

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.

Can someone tell me what I did wrong?

EDIT

I've just tried matching ^Page \d$ also with no results...

1
  • Are you aware what ^ and $ means? Does the meaning apply to those lines? Commented May 3, 2013 at 12:04

4 Answers 4

1

[0-100] is actually 0-1, 0, and 0, not 0-100. Therefore it will only match 0 or 1.

Try this regex:

^Page ([0-9][0-9])|(100)$

It will match Page, then two digits or 100.

If you don't care how big the page numbers can be, just use the "digit" escape sequence:

^Page \d+$
Sign up to request clarification or add additional context in comments.

2 Comments

Still no luck :/ normal if I want to replace /r/n, all I type into the search box is /r/n but that's using Notepad++'s Extended search, not the regex
1

You could

^Page \d+\s*$

Page followed by 1 or more digit followed by any whitespace

Comments

1

Your regex isn't valid. You can't match a number range that way. You have to check each digit.

Comments

1

How about this?

^Page [[:digit:]]+$

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.