RegEx: Match string but only if of certain minimum length -


i have huge number of text documents , try extract specific part each of them. starts "item 7" @ beginning of row , ends "item 8" @ beginning of row. can find part regex:

(^( *)item 7(.+?)^( *)item 8) 

my 2 questions are:

  1. there potentially 2 parts fit description in each of documents. want make sure match second one, substantially longer.

  2. how can extract part using regex in "search , replace" query using notepad++?

i'm not sure if using right tool this.

thanks!

supplement: of answers far did following in notepad++. search for

.*(^( *)item *7(?! a)(?!.^item *7(?! *a))(.+?)^( *)(?=^item 8)).

raplce with

$1

thanks far. works great 1 excepction. i'm afraid have go more detail: most, not all, documents want extract text have table of content. that's why want extract second case of "item 7 item 8", in case there two. there item 7a, in case wonder code.

as realized, there number of documents, have "item 7" header on each page within second case of item 7 item 8. thus, code matches last page of item 7 in instances.

i thought solution might ignore cases of item 7 item 8, if have minimum lenght. specifically, ignore cases of item 7 item 8, if have less 120 signs.

any ideas?

i suggest this:

^item 7(?!.*^item 7).*^item 8 

this finds last of [item 7 - item 8] pairs in document.

it works in notepad++ 6.9.2 using find function, regular expression option, with . matches newline checked.

nb: find in current document button seems use different interpretation of regular expression, apparently ignoring negative look-ahead. solution works find next button.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -