/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