Ortund
Ortund

Reputation: 8245

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

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...

Upvotes: 0

Views: 427

Answers (4)

Noel
Noel

Reputation: 10525

How about this?

^Page [[:digit:]]+$

Upvotes: 1

Kai
Kai

Reputation: 39632

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

Upvotes: 1

Alex K.
Alex K.

Reputation: 175748

You could

^Page \d+\s*$

Page followed by 1 or more digit followed by any whitespace

Upvotes: 1

tckmn
tckmn

Reputation: 59273

[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+$

Upvotes: 1

Related Questions