#include main(args) { test('%<[a-z]+%>(?)', 'a aaa aaaaa aaba aa aaaa'); test('s(?!)', 'this is a test string'); test('(?)s', 'this is a silly test string'); test('(?[a-z]++(?+)word', 'this is a test word, another test word, a non-test regular word'); test('[a-z]++(?+)word', 'this is a test word, another test word, a non-test regular word'); test('(?<=^|[.!?]+)%<%w+%>', 'This is our test. It\'s very nice.'); test('(?<=[.!?]+)%<%w+%>', 'This is our test. It\'s very nice.'); // These are to test loop detection. Assertions don't consume any // input, so applying * to an assertion or group of assertion basically // renders the assertion meaningless; and applying + means we should // just execute the assertion once. test('(?=x)*.*', 'asdf'); // * makes the assertion irrelevant test('((?=x))*.*', 'asdf'); // * makes the assertion irrelevant test('(?=x)+.*', 'asdf'); // + keeps the assertion test('((?=x))+.*', 'asdf'); // + keeps the assertion test('(?=x)+.*', 'xyz'); // + keeps the assertion test('((?=x))+.*', 'xyz'); // + keeps the assertion test('(((?=x)(?=x)(?=x))*)+.*', 'asdf'); // * drops the assertion test('(((?=x)(?=x)(?=x))+)*.*', 'asdf'); // * drops the assertion test('(((?=x)(?=x)(?=x))+)+.*', 'asdf'); // + keeps it test('(((?=x)(?=x)(?=x))+)+.*', 'xyz'); // + keeps it } test(pat, str) { "<>
<>
"; local match = rexSearch(pat, str); if (match) { "<><>
"; "index=<>, length=<>, match=<>
"; } else "nil
"; "
"; }