Note that you have to have the lookahead checked for every character you're accepting. In your case, the [^\n]+ sub-pattern needs to be adjusted to make sure every character is not the beginning of a Lib:Matching a pattern that doesn't include another pattern
You might want to capture everything between foo and bar that doesn't include baz. The technique is to have the regex engine look-ahead at every character to ensure that it isn't the beginning of the undesired pattern:/foo # Match starting at foo ( # Capture (?: # Complex expression: (?!baz) # make sure we're not at the beginning of baz . # accept any character )* # any number of times ) # End capture bar # and ending at bar /x;
(?: # Complex expression: (?!Lib) # make sure we're not at the beginning of Lib [^\n] # accept any character )+ # any positive number of times
In reply to Re: lookahead, lookbehind, ... I'm lost
by Roy Johnson
in thread lookahead, lookbehind, ... I'm lost
by ExReg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |