Hello everyone.

I would like to craft an expression to find lines that contain pattern_2 NOT 
preceded by pattern_1
(with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2).

This is the catch, so let me repeat it with emphasis on IMMEDIATELY:

        with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2


For instance: pattern_1 and pattern_2 distributed thus are of no interest to me:

    pattern_1 immediately preceding pattern_2: pattern_1pattern_2

    A blank between pattern_1 and pattern_2: pattern_1 pattern_2

    Some stuff between pattern_1 and pattern_2: pattern_1 with Some stuff and 
then pattern_2


On the other hand, this is a line of interest that has pattern_2 but absolutely 
no pattern_1 anywhere before:

    Some stuff (possibly nothing) and then pattern_2
    
    
I want the results of my ideal expression to report ONLY the last line in this 
example:

    pattern_1pattern_2
    pattern_1 pattern_2
    pattern_1 with Some stuff and then pattern_2
    Some stuff (possibly nothing) and then pattern_2


I tried:
    (?<!pattern_1)pattern_2

This half-succeeds:
    it doesn't find the first line and it finds the last line 

but half-fails:
    it finds the second and third lines.


I tried::
    (?<!pattern_1).*?pattern_2

This finds ALL the lines, so it fully fails. This is certainly NOT the behavior 
I want.


Lookbehind seems to work only if its pattern precedes another pattern 
IMMEDIATELY
(which sounds to me like an extreme cased of non-greedy behavior).

Any tricks to making Lookbehind "greedy" ?

Even better: Any wise advice regarding SOME simple way to specify what I want?

    Find lines that contain pattern_2 NOT preceded by pattern_1
    (with pattern_1 not necessarily IMMEDIATELY to the left of pattern_2).


Thanks!    

Alfredo

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to