tin
tin

Reputation: 25

Notepad++ Remove line have string length than 10 character

Notepad++ can remove line less than 10 character.

^.{0,9}$

But, if i want remove line have string length than 10 character?

Example:.

hello world, my name Peter.
hello world, mynamePeter.

The string "mynamePeter" have over 10 character, i need remove line container "mynamePeter". How i can do it?

Upvotes: 1

Views: 2948

Answers (2)

Toto
Toto

Reputation: 91488

  • Ctrl+H
  • Find what: ^.*?\b\w{10,}\b*?(?:\R|\z)
  • Replace with: LEAVE EMPTY
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^                   # beginning of line
  .*?               # 0 or more any character but newline
  \b                # word boundary
  \w{10,}           # 10 or more word character
  \b                # word boundary
  .*?               # 0 or more any character but newline
  (?:\R|\z)         # non capture group, end of line or end of file

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

Upvotes: 1

schorsch
schorsch

Reputation: 29

Use .{10,}\r?\n for line longer any 10 char.

Or if word with 10 or more: .*\w{10}.*\r?\n

Upvotes: 3

Related Questions