test(match1, [setup(regexp_init)]) :- regexp_match(subject,'(sub)(.*)').
test(match2, [setup(regexp_init),fail]) :- regexp_match(abcd,'(sub)(.*)').
test(match3, [setup(regexp_init)]) :- regexp_match(abcd,'(a|b|c|d)*').
test(match4, [setup(regexp_init),fail]) :- regexp_match(abcd,'(a|b|c)*').
test(replace1, [setup(regexp_init)]) :- regexp_replace(a0b1c2d3,'[0-9]+','DIGIT',R),
R = aDIGITbDIGITcDIGITdDIGIT.
test(replace1, [setup(regexp_init)]) :- regexp_replace(a0b1c2d3,'[0-9]+','DIGIT',R),
R == aDIGITbDIGITcDIGITdDIGIT.
test(all1, [setup(regexp_init)]) :- regexp_search_all('abcd','[a-c]',All1), print(all1(All1)),nl,
All1 == [a,b,c].
test(all2, [setup(regexp_init)]) :- regexp_search_all('abcd','[c-d]+',All2), print(all2(All2)),nl,
All2 == [cd].
test(all3, [setup(regexp_init)]) :- regexp_search_all('abcd123zzz','([a-d]+)([0-9]*)',All3), print(all3(All3)),nl,
All3 == [abcd123].
test(all4, [setup(regexp_init)]) :- regexp_search_all('abcd123zzz','([e-v]+)([0-9]*)',All4), print(all4(All4)),nl,
All4 == [].
test(all5, [setup(regexp_init)]) :- regexp_search_all('aBCd','[a-c]',All1), print(all5(All1)),nl,
All1 == [a].
test(all1, [setup(regexp_init)]) :- regexp_isearch_all('abcd','[a-c]',All1), print(all1(All1)),nl,
All1 == [a,b,c].
test(all2, [setup(regexp_init)]) :- regexp_isearch_all('abcd','[c-d]+',All2), print(all2(All2)),nl,
All2 == [cd].
test(all3, [setup(regexp_init)]) :- regexp_isearch_all('abcd123zzz','([a-d]+)([0-9]*)',All3), print(all3(All3)),nl,
All3 == [abcd123].
test(all4, [setup(regexp_init)]) :- regexp_isearch_all('abcd123zzz','([e-v]+)([0-9]*)',All4), print(all4(All4)),nl,
All4 == [].
test(all5, [setup(regexp_init)]) :- regexp_isearch_all('aBCd','[a-c]',All1), print(all5(All1)),nl,
All1 == [a,'B','C'].
test(first1, [setup(regexp_init)]) :- regexp_search_first('xxabcd123zzz','([a-d]+)([0-9]*)',R1), print(res1(R1)),nl,
R1 == abcd123.
test(first2, [setup(regexp_init)]) :- regexp_search_first('xxabcd123zzz','([a-d]+)([4-9]+)',R2), print(res2(R2)),nl,
R2 == ''.
test(first3, [setup(regexp_init)]) :- regexp_search_first('küssen','[w]',R3), print(res3(R3)),nl,
R3 == ''.
test(first4, [setup(regexp_init)]) :- regexp_search_first('küssen','[e]',R4), print(res4(R4)),nl,
R4 == 'e'.
test(first5, [setup(regexp_init)]) :- K = 'küssen', L='ü',
regexp_search_first(K,L,R5), format('first5 for ~w and ~w is ~w~n',[K,L,R5]),
R5 == L.
test(first_detailed1, [setup(regexp_init)]) :-
regexp_search_first_detailed('xxabcd123zzz',1,'([a-d]+)([0-9]*)',R10), print(res10(R10)),nl,
R10 == match(2,7,[abcd123,abcd,'123']).
test(first_detailed2, [setup(regexp_init)]) :-
regexp_search_first_detailed('xxabcd123zzz',4,'([a-d]+)([0-9]*)',R11), print(res11(R11)),nl,
R11 == match(3,6,[bcd123,bcd,'123']).
test(first_detailed3, [setup(regexp_init)]) :-
regexp_search_first_detailed('xxabcd123zzz',1,'([a-d]+)([4-9]+)',R12), print(res12(R12)),nl,
R12 == 'no-match'.
test(first_detailed4, [setup(regexp_init)]) :-
regexp_search_first_detailed('xxabcd123zzz',9,'([a-d]+)([0-9]*)',R13), print(res13(R13)),nl,
R13 == 'no-match'.