In this file we check that regular expression lookahead and lookbehind works as expected.

The following four lines are test data
1) Foo 123ABC123
2) Foo    ABC
3) Foo BARABCDEF
4) Foo 123ABCDEF

Run the test cases by entering the following regexes (one at a time).
The lines in the result should be highlighted:

Lookahead
regex: "ABC(?=\d+)" result: 1
regex: "ABC(?=\D+)" result: 3, 4
regex: "ABC(?!\d+)" result: 2, 3, 4

Negative lookahead
regex: "ABC(?!\S+)" result: 2
regex: "ABC(?!\d+)" result: 2, 3, 4

Lookbehind
regex: "(?<=\d)ABC" result: 1, 4
regex: "(?<=\S)ABC" result: 1, 3, 4

Negative lookbehind
regex: "(?<!\d)ABC" result: 2, 3
regex: "(?<!\S)ABC" result: 2
regex: "(?<!\D)ABC" result: 1, 4

Lookbehind + lookahead
regex: "(?<=\S)ABC(?=\S+)" result: 1, 3, 4
regex: "(?<=\d)ABC(?=\D+)" result: 4
regex: "(?<=\D)ABC(?=\D+)" result: 3


Next we check that the captures do not get offset by look-ahead or look-behind by
checking the next regexp and replacement on the line after them. The replace should
just replace '_' with '-':
regex: (?<=\d)(ABC)_(DEF)_(GHI)(?=\d+)
replace: \1-\2-\3
123ABC_DEF_GHI123

Next we check that the captures do not get offset by NEGATIVE look-ahead or
look-behind by checking the next regexp and replacement on the line after them.
The replace should just replace '_' with '-':
regex: (?<!\d)(ABC)_(DEF)_(GHI)(?!\d+)
replace: \1-\2-\3
aaaABC_DEF_GHIaaa

Complex lookahead (with nested parenthesis)
1) xxxrr
2) xxxgs
3) xxxge
4) xxxgr

Find xxx followed by g, but not if g is followed by s
regex: xxx(?=g(?!s))
replace: yyy
result: find & replace 3,4

Complex lookbehind (with nested parenthesis)
1) qwxxx
2) asxxx
3) bsxxx
4) sxxx
5) (sxxx
6) )sxxx

Find xxx after an 's', but not if that 's' is after a 'b' or '(' or ')'
regex: (?<=(?<!(b|\(|[\)]))s)xxx
replace: yyy
result: find & replace 2,4
