Two comments about the suggested pattern

(.{1,}\n){5}

First, the sub-pattern “.{1,}” could also be written as “.+”. The + suffix 
means exactly the same thing as the {1,} suffix, that is, “one or more 
occurrences of the preceding pattern”. It is a personal choice which one you 
prefer. (I believe that the specific suffixes + (1 or more), * (0 or more), and 
? (0 or 1) were part of the GREP pattern language before the more general {m,n} 
(at least m but no more than n).)

Second, if you have more than five consecutive non-blank lines, the suggested 
pattern will match the first five. If you only want to match groups of exactly 
five non-blank lines, I would suggest something like this:

(?<=\n\n|\A)(.{1,}\n){5}$

The (?<=\n\n|\A) prefix says that the following pattern will only match if it 
is preceded by (the ?<= operator) either a blank line (the \n\n — i.e., two 
end-of-lines with nothing between) or (the.| operator) the beginning of the 
document (the \A). Therefore, five consecutive non-blank lines will not match 
the pattern if they are preceded by another non-blank line.

Similarly, the $ suffix says that the pattern must be followed by either 
another end-of-line (i.e., an empty line) or the end of the document. 
Therefore, five consecutive non-blank lines will not match the pattern if they 
are followed by another non-blank line.


> On Jul 29, 2024, at 9:02 AM, [email protected] wrote:
> 
> You can use the repetition modifier on a parentheses group to find a pattern 
> that repeats so many times.
> 
> This will find five repetitions of a line that starts with an alphanumeric 
> character.
> 
> (\w.*?\n){5}
> 
> You can use non-grouping parentheses (:? ... ) if you need to do 
> search/replaces with this.
> 
> [fletcher]
> 
>> On Jul 29, 2024, at 3:11 AM, Otto Munters <[email protected]> wrote:
>> 
>> Hi BB friends
>> 
>> How can I find text blocks consisting of 5 lines?
>> Example:
>> line 1
>> line 2
>> line 3
>> line 4
>> 
>> line 5
>> line 6
>> line 7
>> line 8
>> line 9
>> 
>> I then want to find the second block of text.
>> 
>> thanks for your help!
>> Otto
>> 
>> 
>> -- 
>> This is the BBEdit Talk public discussion group. If you have a feature 
>> request or believe that the application isn't working correctly, please 
>> email "[email protected]" rather than posting here. Follow @bbedit on 
>> Mastodon: <https://mastodon.social/@bbedit>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/bbedit/3bdd6c14-8220-4159-9e0c-7b48aedfa74an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/bbedit/3bdd6c14-8220-4159-9e0c-7b48aedfa74an%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or believe that the application isn't working correctly, please email 
> "[email protected]" rather than posting here. Follow @bbedit on Mastodon: 
> <https://mastodon.social/@bbedit>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/DC7DA668-9137-4D59-B392-3473AC86965F%40cumuli.com
>  
> <https://groups.google.com/d/msgid/bbedit/DC7DA668-9137-4D59-B392-3473AC86965F%40cumuli.com?utm_medium=email&utm_source=footer>.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or believe that the application isn't working correctly, please email 
"[email protected]" rather than posting here. Follow @bbedit on Mastodon: 
<https://mastodon.social/@bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/9D1D5944-BE88-44DA-86D2-4525F6FA74C1%40faiman.org.

Reply via email to