File: regexp_mono_test.go

package info (click to toggle)
golang-github-dlclark-regexp2 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 560 kB
  • sloc: makefile: 3
file content (1081 lines) | stat: -rw-r--r-- 78,637 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
package regexp2

import (
	"fmt"
	"testing"
)

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// https://github.com/mono/mono/blob/master/mcs/class/System/Test/System.Text.RegularExpressions/PerlTrials.cs
// ported from perl-5.6.1/t/op/re_tests

func TestMono_Basics(t *testing.T) {
	runRegexTrial(t, `abc`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc`, 0, "xbc", "Fail.")
	runRegexTrial(t, `abc`, 0, "axc", "Fail.")
	runRegexTrial(t, `abc`, 0, "abx", "Fail.")
	runRegexTrial(t, `abc`, 0, "xabcy", "Pass. Group[0]=(1,3)")
	runRegexTrial(t, `abc`, 0, "ababc", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `ab*c`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, 0, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab*bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `.{1}`, 0, "abbbbc", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `.{3,4}`, 0, "abbbbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab{0,}bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab+bc`, 0, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab+bc`, 0, "abc", "Fail.")
	runRegexTrial(t, `ab+bc`, 0, "abq", "Fail.")
	runRegexTrial(t, `ab{1,}bc`, 0, "abq", "Fail.")
	runRegexTrial(t, `ab+bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,}bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,3}bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{3,4}bc`, 0, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{4,5}bc`, 0, "abbbbc", "Fail.")
	runRegexTrial(t, `ab?bc`, 0, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab?bc`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}bc`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab?bc`, 0, "abbbbc", "Fail.")
	runRegexTrial(t, `ab?c`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}c`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, 0, "abcc", "Fail.")
	runRegexTrial(t, `^abc`, 0, "abcc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, 0, "aabc", "Fail.")
	runRegexTrial(t, `abc$`, 0, "aabc", "Pass. Group[0]=(1,3)")
	runRegexTrial(t, `abc$`, 0, "aabcd", "Fail.")
	runRegexTrial(t, `^`, 0, "abc", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `$`, 0, "abc", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `a.c`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.c`, 0, "axc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.*c`, 0, "axyzc", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `a.*c`, 0, "axyzd", "Fail.")
	runRegexTrial(t, `a[bc]d`, 0, "abc", "Fail.")
	runRegexTrial(t, `a[bc]d`, 0, "abd", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]e`, 0, "abd", "Fail.")
	runRegexTrial(t, `a[b-d]e`, 0, "ace", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]`, 0, "aac", "Pass. Group[0]=(1,2)")
	runRegexTrial(t, `a[-b]`, 0, "a-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-]`, 0, "a-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-a]`, 0, "-", "Error.")
	runRegexTrial(t, `a[]b`, 0, "-", "Error.")
	runRegexTrial(t, `a[`, 0, "-", "Error.")
	runRegexTrial(t, `a]`, 0, "a]", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[]]b`, 0, "a]b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, 0, "aed", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, 0, "abd", "Fail.")
	runRegexTrial(t, `a[^-b]c`, 0, "adc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^-b]c`, 0, "a-c", "Fail.")
	runRegexTrial(t, `a[^]b]c`, 0, "a]c", "Fail.")
	runRegexTrial(t, `a[^]b]c`, 0, "adc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `\ba\b`, 0, "a-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\ba\b`, 0, "-a", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\ba\b`, 0, "-a-", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\by\b`, 0, "xy", "Fail.")
	runRegexTrial(t, `\by\b`, 0, "yz", "Fail.")
	runRegexTrial(t, `\by\b`, 0, "xyz", "Fail.")
	runRegexTrial(t, `\Ba\B`, 0, "a-", "Fail.")
	runRegexTrial(t, `\Ba\B`, 0, "-a", "Fail.")
	runRegexTrial(t, `\Ba\B`, 0, "-a-", "Fail.")
	runRegexTrial(t, `\By\b`, 0, "xy", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\by\B`, 0, "yz", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\By\B`, 0, "xyz", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\w`, 0, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\w`, 0, "-", "Fail.")
	runRegexTrial(t, `\W`, 0, "a", "Fail.")
	runRegexTrial(t, `\W`, 0, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a\sb`, 0, "a b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a\sb`, 0, "a-b", "Fail.")
	runRegexTrial(t, `a\Sb`, 0, "a b", "Fail.")
	runRegexTrial(t, `a\Sb`, 0, "a-b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `\d`, 0, "1", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\d`, 0, "-", "Fail.")
	runRegexTrial(t, `\D`, 0, "1", "Fail.")
	runRegexTrial(t, `\D`, 0, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\w]`, 0, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\w]`, 0, "-", "Fail.")
	runRegexTrial(t, `[\W]`, 0, "a", "Fail.")
	runRegexTrial(t, `[\W]`, 0, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a[\s]b`, 0, "a b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[\s]b`, 0, "a-b", "Fail.")
	runRegexTrial(t, `a[\S]b`, 0, "a b", "Fail.")
	runRegexTrial(t, `a[\S]b`, 0, "a-b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `[\d]`, 0, "1", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\d]`, 0, "-", "Fail.")
	runRegexTrial(t, `[\D]`, 0, "1", "Fail.")
	runRegexTrial(t, `[\D]`, 0, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `ab|cd`, 0, "abc", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `ab|cd`, 0, "abcd", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `()ef`, 0, "def", "Pass. Group[0]=(1,2) Group[1]=(1,0)")
	runRegexTrial(t, `*a`, 0, "-", "Error.")
	runRegexTrial(t, `(*)b`, 0, "-", "Error.")
	runRegexTrial(t, `$b`, 0, "b", "Fail.")
	runRegexTrial(t, `a\`, 0, "-", "Error.")
	runRegexTrial(t, `a\(b`, 0, "a(b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a\(*b`, 0, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a\(*b`, 0, "a((b", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a\\b`, 0, "a\\b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc)`, 0, "-", "Error.")
	runRegexTrial(t, `(abc`, 0, "-", "Error.")
	runRegexTrial(t, `((a))`, 0, "abc", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1)")
	runRegexTrial(t, `(a)b(c)`, 0, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(2,1)")
	runRegexTrial(t, `a+b+c`, 0, "aabbabc", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a{1,}b{1,}c`, 0, "aabbabc", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a**`, 0, "-", "Error.")
	runRegexTrial(t, `a.+?c`, 0, "abcabc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `(a+|b)*`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b){0,}`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b)+`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b){1,}`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b)?`, 0, "ab", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(a+|b){0,1}`, 0, "ab", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `)(`, 0, "-", "Error.")
	runRegexTrial(t, `[^ab]*`, 0, "cde", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc`, 0, "", "Fail.")
	runRegexTrial(t, `a*`, 0, "", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `([abc])*d`, 0, "abbbcd", "Pass. Group[0]=(0,6) Group[1]=(0,1)(1,1)(2,1)(3,1)(4,1)")
	runRegexTrial(t, `([abc])*bcd`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(0,1)")
	runRegexTrial(t, `a|b|c|d|e`, 0, "e", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(a|b|c|d|e)f`, 0, "ef", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `abcd*efg`, 0, "abcdefg", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `ab*`, 0, "xabyabbbz", "Pass. Group[0]=(1,2)")
	runRegexTrial(t, `ab*`, 0, "xayabbbz", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(ab|cd)e`, 0, "abcde", "Pass. Group[0]=(2,3) Group[1]=(2,2)")
	runRegexTrial(t, `[abhgefdc]ij`, 0, "hij", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^(ab|cd)e`, 0, "abcde", "Fail.")
	runRegexTrial(t, `(abc|)ef`, 0, "abcdef", "Pass. Group[0]=(4,2) Group[1]=(4,0)")
	runRegexTrial(t, `(a|b)c*d`, 0, "abcd", "Pass. Group[0]=(1,3) Group[1]=(1,1)")
	runRegexTrial(t, `(ab|ab*)bc`, 0, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,1)")
	runRegexTrial(t, `a([bc]*)c*`, 0, "abc", "Pass. Group[0]=(0,3) Group[1]=(1,2)")
	runRegexTrial(t, `a([bc]*)(c*d)`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,2) Group[2]=(3,1)")
	runRegexTrial(t, `a([bc]+)(c*d)`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,2) Group[2]=(3,1)")
	runRegexTrial(t, `a([bc]*)(c+d)`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,1) Group[2]=(2,2)")
	runRegexTrial(t, `a[bcd]*dcdcde`, 0, "adcdcde", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `a[bcd]+dcdcde`, 0, "adcdcde", "Fail.")
	runRegexTrial(t, `(ab|a)b*c`, 0, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,2)")
	runRegexTrial(t, `((a)(b)c)(d)`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(0,3) Group[2]=(0,1) Group[3]=(1,1) Group[4]=(3,1)")
	runRegexTrial(t, `[a-zA-Z_][a-zA-Z0-9_]*`, 0, "alpha", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `^a(bc+|b[eh])g|.h$`, 0, "abh", "Pass. Group[0]=(1,2) Group[1]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, 0, "effgz", "Pass. Group[0]=(0,5) Group[1]=(0,5) Group[2]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, 0, "ij", "Pass. Group[0]=(0,2) Group[1]=(0,2) Group[2]=(1,1)")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, 0, "effg", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, 0, "bcdd", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, 0, "reffgz", "Pass. Group[0]=(1,5) Group[1]=(1,5) Group[2]=")
	runRegexTrial(t, `((((((((((a))))))))))`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `((((((((((a))))))))))\10`, 0, "aa", "Pass. Group[0]=(0,2) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `((((((((((a))))))))))!`, 0, "aa", "Fail.")
	runRegexTrial(t, `((((((((((a))))))))))!`, 0, "a!", "Pass. Group[0]=(0,2) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `(((((((((a)))))))))`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1)")
	runRegexTrial(t, `multiple words of text`, 0, "uh-uh", "Fail.")
	runRegexTrial(t, `multiple words`, 0, "multiple words, yeah", "Pass. Group[0]=(0,14)")
	runRegexTrial(t, `(.*)c(.*)`, 0, "abcde", "Pass. Group[0]=(0,5) Group[1]=(0,2) Group[2]=(3,2)")
	runRegexTrial(t, `\((.*), (.*)\)`, 0, "(a, b)", "Pass. Group[0]=(0,6) Group[1]=(1,1) Group[2]=(4,1)")
	runRegexTrial(t, `[k]`, 0, "ab", "Fail.")
	runRegexTrial(t, `abcd`, 0, "abcd", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a(bc)d`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,2)")
	runRegexTrial(t, `a[-]?c`, 0, "ac", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `(abc)\1`, 0, "abcabc", "Pass. Group[0]=(0,6) Group[1]=(0,3)")
	runRegexTrial(t, `([a-c]*)\1`, 0, "abcabc", "Pass. Group[0]=(0,6) Group[1]=(0,3)")
	runRegexTrial(t, `\1`, 0, "-", "Error.")
	runRegexTrial(t, `\2`, 0, "-", "Error.")
	runRegexTrial(t, `(a)|\1`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(a)|\1`, 0, "x", "Fail.")
	runRegexTrial(t, `(a)|\2`, 0, "-", "Error.")
	runRegexTrial(t, `(([a-c])b*?\2)*`, 0, "ababbbcbc", "Pass. Group[0]=(0,5) Group[1]=(0,3)(3,2) Group[2]=(0,1)(3,1)")
	runRegexTrial(t, `(([a-c])b*?\2){3}`, 0, "ababbbcbc", "Pass. Group[0]=(0,9) Group[1]=(0,3)(3,3)(6,3) Group[2]=(0,1)(3,1)(6,1)")
	runRegexTrial(t, `((\3|b)\2(a)x)+`, 0, "aaxabxbaxbbx", "Fail.")
	runRegexTrial(t, `((\3|b)\2(a)x)+`, 0, "aaaxabaxbaaxbbax", "Pass. Group[0]=(12,4) Group[1]=(12,4) Group[2]=(12,1) Group[3]=(14,1)")
	runRegexTrial(t, `((\3|b)\2(a)){2,}`, 0, "bbaababbabaaaaabbaaaabba", "Pass. Group[0]=(15,9) Group[1]=(15,3)(18,3)(21,3) Group[2]=(15,1)(18,1)(21,1) Group[3]=(17,1)(20,1)(23,1)")
	runRegexTrial(t, `abc`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc`, IgnoreCase, "XBC", "Fail.")
	runRegexTrial(t, `abc`, IgnoreCase, "AXC", "Fail.")
	runRegexTrial(t, `abc`, IgnoreCase, "ABX", "Fail.")
	runRegexTrial(t, `abc`, IgnoreCase, "XABCY", "Pass. Group[0]=(1,3)")
	runRegexTrial(t, `abc`, IgnoreCase, "ABABC", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `ab*c`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, IgnoreCase, "ABBC", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab*?bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{0,}?bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab+?bc`, IgnoreCase, "ABBC", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab+bc`, IgnoreCase, "ABC", "Fail.")
	runRegexTrial(t, `ab+bc`, IgnoreCase, "ABQ", "Fail.")
	runRegexTrial(t, `ab{1,}bc`, IgnoreCase, "ABQ", "Fail.")
	runRegexTrial(t, `ab+bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,}?bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,3}?bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{3,4}?bc`, IgnoreCase, "ABBBBC", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{4,5}?bc`, IgnoreCase, "ABBBBC", "Fail.")
	runRegexTrial(t, `ab??bc`, IgnoreCase, "ABBC", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab??bc`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}?bc`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab??bc`, IgnoreCase, "ABBBBC", "Fail.")
	runRegexTrial(t, `ab??c`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}?c`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, IgnoreCase, "ABCC", "Fail.")
	runRegexTrial(t, `^abc`, IgnoreCase, "ABCC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, IgnoreCase, "AABC", "Fail.")
	runRegexTrial(t, `abc$`, IgnoreCase, "AABC", "Pass. Group[0]=(1,3)")
	runRegexTrial(t, `^`, IgnoreCase, "ABC", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `$`, IgnoreCase, "ABC", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `a.c`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.c`, IgnoreCase, "AXC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.*?c`, IgnoreCase, "AXYZC", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `a.*c`, IgnoreCase, "AXYZD", "Fail.")
	runRegexTrial(t, `a[bc]d`, IgnoreCase, "ABC", "Fail.")
	runRegexTrial(t, `a[bc]d`, IgnoreCase, "ABD", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]e`, IgnoreCase, "ABD", "Fail.")
	runRegexTrial(t, `a[b-d]e`, IgnoreCase, "ACE", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]`, IgnoreCase, "AAC", "Pass. Group[0]=(1,2)")
	runRegexTrial(t, `a[-b]`, IgnoreCase, "A-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-]`, IgnoreCase, "A-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-a]`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `a[]b`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `a[`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `a]`, IgnoreCase, "A]", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[]]b`, IgnoreCase, "A]B", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, IgnoreCase, "AED", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, IgnoreCase, "ABD", "Fail.")
	runRegexTrial(t, `a[^-b]c`, IgnoreCase, "ADC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^-b]c`, IgnoreCase, "A-C", "Fail.")
	runRegexTrial(t, `a[^]b]c`, IgnoreCase, "A]C", "Fail.")
	runRegexTrial(t, `a[^]b]c`, IgnoreCase, "ADC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab|cd`, IgnoreCase, "ABC", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `ab|cd`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `()ef`, IgnoreCase, "DEF", "Pass. Group[0]=(1,2) Group[1]=(1,0)")
	runRegexTrial(t, `*a`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `(*)b`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `$b`, IgnoreCase, "B", "Fail.")
	runRegexTrial(t, `a\`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `a\(b`, IgnoreCase, "A(B", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a\(*b`, IgnoreCase, "AB", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a\(*b`, IgnoreCase, "A((B", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a\\b`, IgnoreCase, "A\\B", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc)`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `(abc`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `((a))`, IgnoreCase, "ABC", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1)")
	runRegexTrial(t, `(a)b(c)`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(2,1)")
	runRegexTrial(t, `a+b+c`, IgnoreCase, "AABBABC", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a{1,}b{1,}c`, IgnoreCase, "AABBABC", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a**`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `a.+?c`, IgnoreCase, "ABCABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.*?c`, IgnoreCase, "ABCABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.{0,5}?c`, IgnoreCase, "ABCABC", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `(a+|b)*`, IgnoreCase, "AB", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b){0,}`, IgnoreCase, "AB", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b)+`, IgnoreCase, "AB", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b){1,}`, IgnoreCase, "AB", "Pass. Group[0]=(0,2) Group[1]=(0,1)(1,1)")
	runRegexTrial(t, `(a+|b)?`, IgnoreCase, "AB", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(a+|b){0,1}`, IgnoreCase, "AB", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(a+|b){0,1}?`, IgnoreCase, "AB", "Pass. Group[0]=(0,0) Group[1]=")
	runRegexTrial(t, `)(`, IgnoreCase, "-", "Error.")
	runRegexTrial(t, `[^ab]*`, IgnoreCase, "CDE", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc`, IgnoreCase, "", "Fail.")
	runRegexTrial(t, `a*`, IgnoreCase, "", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `([abc])*d`, IgnoreCase, "ABBBCD", "Pass. Group[0]=(0,6) Group[1]=(0,1)(1,1)(2,1)(3,1)(4,1)")
	runRegexTrial(t, `([abc])*bcd`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(0,1)")
	runRegexTrial(t, `a|b|c|d|e`, IgnoreCase, "E", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(a|b|c|d|e)f`, IgnoreCase, "EF", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `abcd*efg`, IgnoreCase, "ABCDEFG", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `ab*`, IgnoreCase, "XABYABBBZ", "Pass. Group[0]=(1,2)")
	runRegexTrial(t, `ab*`, IgnoreCase, "XAYABBBZ", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(ab|cd)e`, IgnoreCase, "ABCDE", "Pass. Group[0]=(2,3) Group[1]=(2,2)")
	runRegexTrial(t, `[abhgefdc]ij`, IgnoreCase, "HIJ", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^(ab|cd)e`, IgnoreCase, "ABCDE", "Fail.")
	runRegexTrial(t, `(abc|)ef`, IgnoreCase, "ABCDEF", "Pass. Group[0]=(4,2) Group[1]=(4,0)")
	runRegexTrial(t, `(a|b)c*d`, IgnoreCase, "ABCD", "Pass. Group[0]=(1,3) Group[1]=(1,1)")
	runRegexTrial(t, `(ab|ab*)bc`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3) Group[1]=(0,1)")
	runRegexTrial(t, `a([bc]*)c*`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3) Group[1]=(1,2)")
	runRegexTrial(t, `a([bc]*)(c*d)`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(1,2) Group[2]=(3,1)")
	runRegexTrial(t, `a([bc]+)(c*d)`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(1,2) Group[2]=(3,1)")
	runRegexTrial(t, `a([bc]*)(c+d)`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(1,1) Group[2]=(2,2)")
	runRegexTrial(t, `a[bcd]*dcdcde`, IgnoreCase, "ADCDCDE", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `a[bcd]+dcdcde`, IgnoreCase, "ADCDCDE", "Fail.")
	runRegexTrial(t, `(ab|a)b*c`, IgnoreCase, "ABC", "Pass. Group[0]=(0,3) Group[1]=(0,2)")
	runRegexTrial(t, `((a)(b)c)(d)`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(0,3) Group[2]=(0,1) Group[3]=(1,1) Group[4]=(3,1)")
	runRegexTrial(t, `[a-zA-Z_][a-zA-Z0-9_]*`, IgnoreCase, "ALPHA", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `^a(bc+|b[eh])g|.h$`, IgnoreCase, "ABH", "Pass. Group[0]=(1,2) Group[1]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, IgnoreCase, "EFFGZ", "Pass. Group[0]=(0,5) Group[1]=(0,5) Group[2]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, IgnoreCase, "IJ", "Pass. Group[0]=(0,2) Group[1]=(0,2) Group[2]=(1,1)")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, IgnoreCase, "EFFG", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, IgnoreCase, "BCDD", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, IgnoreCase, "REFFGZ", "Pass. Group[0]=(1,5) Group[1]=(1,5) Group[2]=")
	runRegexTrial(t, `((((((((((a))))))))))`, IgnoreCase, "A", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `((((((((((a))))))))))\10`, IgnoreCase, "AA", "Pass. Group[0]=(0,2) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `((((((((((a))))))))))!`, IgnoreCase, "AA", "Fail.")
	runRegexTrial(t, `((((((((((a))))))))))!`, IgnoreCase, "A!", "Pass. Group[0]=(0,2) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `(((((((((a)))))))))`, IgnoreCase, "A", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1)")
	runRegexTrial(t, `(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))`, IgnoreCase, "A", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))`, IgnoreCase, "C", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `multiple words of text`, IgnoreCase, "UH-UH", "Fail.")
	runRegexTrial(t, `multiple words`, IgnoreCase, "MULTIPLE WORDS, YEAH", "Pass. Group[0]=(0,14)")
	runRegexTrial(t, `(.*)c(.*)`, IgnoreCase, "ABCDE", "Pass. Group[0]=(0,5) Group[1]=(0,2) Group[2]=(3,2)")
	runRegexTrial(t, `\((.*), (.*)\)`, IgnoreCase, "(A, B)", "Pass. Group[0]=(0,6) Group[1]=(1,1) Group[2]=(4,1)")
	runRegexTrial(t, `[k]`, IgnoreCase, "AB", "Fail.")
	runRegexTrial(t, `abcd`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a(bc)d`, IgnoreCase, "ABCD", "Pass. Group[0]=(0,4) Group[1]=(1,2)")
	runRegexTrial(t, `a[-]?c`, IgnoreCase, "AC", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `(abc)\1`, IgnoreCase, "ABCABC", "Pass. Group[0]=(0,6) Group[1]=(0,3)")
	runRegexTrial(t, `([a-c]*)\1`, IgnoreCase, "ABCABC", "Pass. Group[0]=(0,6) Group[1]=(0,3)")
	runRegexTrial(t, `a(?!b).`, 0, "abad", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `a(?=d).`, 0, "abad", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `a(?=c|d).`, 0, "abad", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `a(?:b|c|d)(.)`, 0, "ace", "Pass. Group[0]=(0,3) Group[1]=(2,1)")
	runRegexTrial(t, `a(?:b|c|d)*(.)`, 0, "ace", "Pass. Group[0]=(0,3) Group[1]=(2,1)")
	runRegexTrial(t, `a(?:b|c|d)+?(.)`, 0, "ace", "Pass. Group[0]=(0,3) Group[1]=(2,1)")
	runRegexTrial(t, `a(?:b|c|d)+?(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,3) Group[1]=(2,1)")
	runRegexTrial(t, `a(?:b|c|d)+(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,8) Group[1]=(7,1)")
	runRegexTrial(t, `a(?:b|c|d){2}(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,4) Group[1]=(3,1)")
	runRegexTrial(t, `a(?:b|c|d){4,5}(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,7) Group[1]=(6,1)")
	runRegexTrial(t, `a(?:b|c|d){4,5}?(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,6) Group[1]=(5,1)")
	runRegexTrial(t, `((foo)|(bar))*`, 0, "foobar", "Pass. Group[0]=(0,6) Group[1]=(0,3)(3,3) Group[2]=(0,3) Group[3]=(3,3)")
	runRegexTrial(t, `:(?:`, 0, "-", "Error.")
	runRegexTrial(t, `a(?:b|c|d){6,7}(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,8) Group[1]=(7,1)")
	runRegexTrial(t, `a(?:b|c|d){6,7}?(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,8) Group[1]=(7,1)")
	runRegexTrial(t, `a(?:b|c|d){5,6}(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,8) Group[1]=(7,1)")
	runRegexTrial(t, `a(?:b|c|d){5,6}?(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,7) Group[1]=(6,1)")
	runRegexTrial(t, `a(?:b|c|d){5,7}(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,8) Group[1]=(7,1)")
	runRegexTrial(t, `a(?:b|c|d){5,7}?(.)`, 0, "acdbcdbe", "Pass. Group[0]=(0,7) Group[1]=(6,1)")
	runRegexTrial(t, `a(?:b|(c|e){1,2}?|d)+?(.)`, 0, "ace", "Pass. Group[0]=(0,3) Group[1]=(1,1) Group[2]=(2,1)")
	runRegexTrial(t, `^(.+)?B`, 0, "AB", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `^([^a-z])|(\^)$`, 0, ".", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=")
	runRegexTrial(t, `^[<>]&`, 0, "<&OUT", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `^(a\1?){4}$`, 0, "aaaaaaaaaa", "Pass. Group[0]=(0,10) Group[1]=(0,1)(1,2)(3,3)(6,4)")
	runRegexTrial(t, `^(a\1?){4}$`, 0, "aaaaaaaaa", "Fail.")
	runRegexTrial(t, `^(a\1?){4}$`, 0, "aaaaaaaaaaa", "Fail.")
	runRegexTrial(t, `^(a(?(1)\1)){4}$`, 0, "aaaaaaaaaa", "Pass. Group[0]=(0,10) Group[1]=(0,1)(1,2)(3,3)(6,4)")
	runRegexTrial(t, `^(a(?(1)\1)){4}$`, 0, "aaaaaaaaa", "Fail.")
	runRegexTrial(t, `^(a(?(1)\1)){4}$`, 0, "aaaaaaaaaaa", "Fail.")
	runRegexTrial(t, `((a{4})+)`, 0, "aaaaaaaaa", "Pass. Group[0]=(0,8) Group[1]=(0,8) Group[2]=(0,4)(4,4)")
	runRegexTrial(t, `(((aa){2})+)`, 0, "aaaaaaaaaa", "Pass. Group[0]=(0,8) Group[1]=(0,8) Group[2]=(0,4)(4,4) Group[3]=(0,2)(2,2)(4,2)(6,2)")
	runRegexTrial(t, `(((a{2}){2})+)`, 0, "aaaaaaaaaa", "Pass. Group[0]=(0,8) Group[1]=(0,8) Group[2]=(0,4)(4,4) Group[3]=(0,2)(2,2)(4,2)(6,2)")
	runRegexTrial(t, `(?:(f)(o)(o)|(b)(a)(r))*`, 0, "foobar", "Pass. Group[0]=(0,6) Group[1]=(0,1) Group[2]=(1,1) Group[3]=(2,1) Group[4]=(3,1) Group[5]=(4,1) Group[6]=(5,1)")
	runRegexTrial(t, `(?<=a)b`, 0, "ab", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(?<=a)b`, 0, "cb", "Fail.")
	runRegexTrial(t, `(?<=a)b`, 0, "b", "Fail.")
	runRegexTrial(t, `(?<!c)b`, 0, "ab", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(?<!c)b`, 0, "cb", "Fail.")
	runRegexTrial(t, `(?<!c)b`, 0, "b", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(?<!c)b`, 0, "b", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(?<%)b`, 0, "-", "Error.")
	runRegexTrial(t, `(?:..)*a`, 0, "aba", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `(?:..)*?a`, 0, "aba", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `^(?:b|a(?=(.)))*\1`, 0, "abc", "Pass. Group[0]=(0,2) Group[1]=(1,1)")
	runRegexTrial(t, `^(){3,5}`, 0, "abc", "Pass. Group[0]=(0,0) Group[1]=(0,0)(0,0)(0,0)")
	runRegexTrial(t, `^(a+)*ax`, 0, "aax", "Pass. Group[0]=(0,3) Group[1]=(0,1)")
	runRegexTrial(t, `^((a|b)+)*ax`, 0, "aax", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(0,1)")
	runRegexTrial(t, `^((a|bc)+)*ax`, 0, "aax", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(0,1)")
	runRegexTrial(t, `(a|x)*ab`, 0, "cab", "Pass. Group[0]=(1,2) Group[1]=")
	runRegexTrial(t, `(a)*ab`, 0, "cab", "Pass. Group[0]=(1,2) Group[1]=")
	runRegexTrial(t, `(?:(?i)a)b`, 0, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?i)a)b`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?i)a)b`, 0, "Ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?i)a)b`, 0, "Ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?i)a)b`, 0, "aB", "Fail.")
	runRegexTrial(t, `((?i)a)b`, 0, "aB", "Fail.")
	runRegexTrial(t, `(?i:a)b`, 0, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?i:a))b`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?i:a)b`, 0, "Ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?i:a))b`, 0, "Ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?i:a)b`, 0, "aB", "Fail.")
	runRegexTrial(t, `((?i:a))b`, 0, "aB", "Fail.")
	runRegexTrial(t, `(?:(?-i)a)b`, IgnoreCase, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i)a)b`, IgnoreCase, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?-i)a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i)a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?-i)a)b`, IgnoreCase, "Ab", "Fail.")
	runRegexTrial(t, `((?-i)a)b`, IgnoreCase, "Ab", "Fail.")
	runRegexTrial(t, `(?:(?-i)a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i)a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?:(?-i)a)b`, IgnoreCase, "AB", "Fail.")
	runRegexTrial(t, `((?-i)a)b`, IgnoreCase, "AB", "Fail.")
	runRegexTrial(t, `(?-i:a)b`, IgnoreCase, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i:a))b`, IgnoreCase, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?-i:a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i:a))b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?-i:a)b`, IgnoreCase, "Ab", "Fail.")
	runRegexTrial(t, `((?-i:a))b`, IgnoreCase, "Ab", "Fail.")
	runRegexTrial(t, `(?-i:a)b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `((?-i:a))b`, IgnoreCase, "aB", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `(?-i:a)b`, IgnoreCase, "AB", "Fail.")
	runRegexTrial(t, `((?-i:a))b`, IgnoreCase, "AB", "Fail.")
	runRegexTrial(t, `((?-i:a.))b`, IgnoreCase, "a\nB", "Fail.")
	runRegexTrial(t, `((?s-i:a.))b`, IgnoreCase, "a\nB", "Pass. Group[0]=(0,3) Group[1]=(0,2)")
	runRegexTrial(t, `((?s-i:a.))b`, IgnoreCase, "B\nB", "Fail.")
	runRegexTrial(t, `(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))`, 0, "cabbbb", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))`, 0, "caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "Pass. Group[0]=(0,41)")
	runRegexTrial(t, `(ab)\d\1`, IgnoreCase, "Ab4ab", "Pass. Group[0]=(0,5) Group[1]=(0,2)")
	runRegexTrial(t, `(ab)\d\1`, IgnoreCase, "ab4Ab", "Pass. Group[0]=(0,5) Group[1]=(0,2)")
	runRegexTrial(t, `foo\w*\d{4}baz`, 0, "foobar1234baz", "Pass. Group[0]=(0,13)")
	runRegexTrial(t, `x(~~)*(?:(?:F)?)?`, 0, "x~~", "Pass. Group[0]=(0,3) Group[1]=(1,2)")
	runRegexTrial(t, `^a(?#xxx){3}c`, 0, "aaac", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `(?<![cd])b`, 0, "dbcb", "Fail.")
	runRegexTrial(t, `(?<![cd])[ab]`, 0, "dbaacb", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `(?<!(c|d))b`, 0, "dbcb", "Fail.")
	runRegexTrial(t, `(?<!(c|d))[ab]`, 0, "dbaacb", "Pass. Group[0]=(2,1) Group[1]=")
	runRegexTrial(t, `(?<!cd)[ab]`, 0, "cdaccb", "Pass. Group[0]=(5,1)")
	runRegexTrial(t, `^(?:a?b?)*$`, 0, "a--", "Fail.")
	runRegexTrial(t, `((?s)^a(.))((?m)^b$)`, 0, "a\nb\nc\n", "Pass. Group[0]=(0,3) Group[1]=(0,2) Group[2]=(1,1) Group[3]=(2,1)")
	runRegexTrial(t, `((?m)^b$)`, 0, "a\nb\nc\n", "Pass. Group[0]=(2,1) Group[1]=(2,1)")
	runRegexTrial(t, `(?m)^b`, 0, "a\nb\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `(?m)^(b)`, 0, "a\nb\n", "Pass. Group[0]=(2,1) Group[1]=(2,1)")
	runRegexTrial(t, `((?m)^b)`, 0, "a\nb\n", "Pass. Group[0]=(2,1) Group[1]=(2,1)")
	runRegexTrial(t, `\n((?m)^b)`, 0, "a\nb\n", "Pass. Group[0]=(1,2) Group[1]=(2,1)")
	runRegexTrial(t, `((?s).)c(?!.)`, 0, "a\nb\nc\n", "Pass. Group[0]=(3,2) Group[1]=(3,1)")
	runRegexTrial(t, `((?s).)c(?!.)`, 0, "a\nb\nc\n", "Pass. Group[0]=(3,2) Group[1]=(3,1)")
	runRegexTrial(t, `((?s)b.)c(?!.)`, 0, "a\nb\nc\n", "Pass. Group[0]=(2,3) Group[1]=(2,2)")
	runRegexTrial(t, `((?s)b.)c(?!.)`, 0, "a\nb\nc\n", "Pass. Group[0]=(2,3) Group[1]=(2,2)")
	runRegexTrial(t, `^b`, 0, "a\nb\nc\n", "Fail.")
	runRegexTrial(t, `()^b`, 0, "a\nb\nc\n", "Fail.")
	runRegexTrial(t, `((?m)^b)`, 0, "a\nb\nc\n", "Pass. Group[0]=(2,1) Group[1]=(2,1)")
	runRegexTrial(t, `(x)?(?(1)a|b)`, 0, "a", "Fail.")
	runRegexTrial(t, `(x)?(?(1)b|a)`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=")
	runRegexTrial(t, `()?(?(1)b|a)`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=")
	runRegexTrial(t, `()(?(1)b|a)`, 0, "a", "Fail.")
	runRegexTrial(t, `()?(?(1)a|b)`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=(0,0)")
	runRegexTrial(t, `^(\()?blah(?(1)(\)))$`, 0, "(blah)", "Pass. Group[0]=(0,6) Group[1]=(0,1) Group[2]=(5,1)")
	runRegexTrial(t, `^(\()?blah(?(1)(\)))$`, 0, "blah", "Pass. Group[0]=(0,4) Group[1]= Group[2]=")
	runRegexTrial(t, `^(\()?blah(?(1)(\)))$`, 0, "blah)", "Fail.")
	runRegexTrial(t, `^(\()?blah(?(1)(\)))$`, 0, "(blah", "Fail.")
	runRegexTrial(t, `^(\(+)?blah(?(1)(\)))$`, 0, "(blah)", "Pass. Group[0]=(0,6) Group[1]=(0,1) Group[2]=(5,1)")
	runRegexTrial(t, `^(\(+)?blah(?(1)(\)))$`, 0, "blah", "Pass. Group[0]=(0,4) Group[1]= Group[2]=")
	runRegexTrial(t, `^(\(+)?blah(?(1)(\)))$`, 0, "blah)", "Fail.")
	runRegexTrial(t, `^(\(+)?blah(?(1)(\)))$`, 0, "(blah", "Fail.")
	runRegexTrial(t, `(?(1)a|b|c)`, 0, "a", "Error.")
	runRegexTrial(t, `(?(?!a)a|b)`, 0, "a", "Fail.")
	runRegexTrial(t, `(?(?!a)b|a)`, 0, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(?(?=a)b|a)`, 0, "a", "Fail.")
	runRegexTrial(t, `(?(?=a)a|b)`, 0, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(?=(a+?))(\1ab)`, 0, "aaab", "Pass. Group[0]=(1,3) Group[1]=(1,1) Group[2]=(1,3)")
	runRegexTrial(t, `^(?=(a+?))\1ab`, 0, "aaab", "Fail.")
	runRegexTrial(t, `(\w+:)+`, 0, "one:", "Pass. Group[0]=(0,4) Group[1]=(0,4)")
	runRegexTrial(t, `$(?<=^(a))`, 0, "a", "Pass. Group[0]=(1,0) Group[1]=(0,1)")
	runRegexTrial(t, `(?=(a+?))(\1ab)`, 0, "aaab", "Pass. Group[0]=(1,3) Group[1]=(1,1) Group[2]=(1,3)")
	runRegexTrial(t, `^(?=(a+?))\1ab`, 0, "aaab", "Fail.")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "abcd:", "Fail.")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]= Group[2]=(0,4)")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "xy:z:::abcd", "Pass. Group[0]=(0,11) Group[1]=(0,7) Group[2]=(7,4)")
	runRegexTrial(t, `^[^bcd]*(c+)`, 0, "aexycd", "Pass. Group[0]=(0,5) Group[1]=(4,1)")
	runRegexTrial(t, `(a*)b+`, 0, "caab", "Pass. Group[0]=(1,3) Group[1]=(1,2)")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "abcd:", "Fail.")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "abcd", "Pass. Group[0]=(0,4) Group[1]= Group[2]=(0,4)")
	runRegexTrial(t, `([\w:]+::)?(\w+)$`, 0, "xy:z:::abcd", "Pass. Group[0]=(0,11) Group[1]=(0,7) Group[2]=(7,4)")
	runRegexTrial(t, `^[^bcd]*(c+)`, 0, "aexycd", "Pass. Group[0]=(0,5) Group[1]=(4,1)")
	runRegexTrial(t, `(>a+)ab`, 0, "aaab", "Fail.")
	runRegexTrial(t, `(?>a+)b`, 0, "aaab", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `([[:]+)`, 0, "a:[b]:", "Pass. Group[0]=(1,2) Group[1]=(1,2)")
	runRegexTrial(t, `([[=]+)`, 0, "a=[b]=", "Pass. Group[0]=(1,2) Group[1]=(1,2)")
	runRegexTrial(t, `([[.]+)`, 0, "a.[b].", "Pass. Group[0]=(1,2) Group[1]=(1,2)")
	runRegexTrial(t, `[a[:]b[:c]`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `[a[:]b[:c]`, 0, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `((?>a+)b)`, 0, "aaab", "Pass. Group[0]=(0,4) Group[1]=(0,4)")
	runRegexTrial(t, `(?>(a+))b`, 0, "aaab", "Pass. Group[0]=(0,4) Group[1]=(0,3)")
	runRegexTrial(t, `((?>[^()]+)|\([^()]*\))+`, 0, "((abc(ade)ufh()()x", "Pass. Group[0]=(2,16) Group[1]=(2,3)(5,5)(10,3)(13,2)(15,2)(17,1)")
	runRegexTrial(t, `(?<=x+)`, 0, "xxxxy", "Pass. Group[0]=(1,0)")
	runRegexTrial(t, `a{37,17}`, 0, "-", "Error.")
	runRegexTrial(t, `\Z`, 0, "a\nb\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, 0, "a\nb\n", "Pass. Group[0]=(4,0)")
	runRegexTrial(t, `$`, 0, "a\nb\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\Z`, 0, "b\na\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, 0, "b\na\n", "Pass. Group[0]=(4,0)")
	runRegexTrial(t, `$`, 0, "b\na\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\Z`, 0, "b\na", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, 0, "b\na", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `$`, 0, "b\na", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\Z`, Multiline, "a\nb\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, Multiline, "a\nb\n", "Pass. Group[0]=(4,0)")
	runRegexTrial(t, `$`, Multiline, "a\nb\n", "Pass. Group[0]=(1,0)")
	runRegexTrial(t, `\Z`, Multiline, "b\na\n", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, Multiline, "b\na\n", "Pass. Group[0]=(4,0)")
	runRegexTrial(t, `$`, Multiline, "b\na\n", "Pass. Group[0]=(1,0)")
	runRegexTrial(t, `\Z`, Multiline, "b\na", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `\z`, Multiline, "b\na", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `$`, Multiline, "b\na", "Pass. Group[0]=(1,0)")
	runRegexTrial(t, `a\Z`, 0, "a\nb\n", "Fail.")
	runRegexTrial(t, `a\z`, 0, "a\nb\n", "Fail.")
	runRegexTrial(t, `a$`, 0, "a\nb\n", "Fail.")
	runRegexTrial(t, `a\Z`, 0, "b\na\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\z`, 0, "b\na\n", "Fail.")
	runRegexTrial(t, `a$`, 0, "b\na\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\Z`, 0, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\z`, 0, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a$`, 0, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\z`, Multiline, "a\nb\n", "Fail.")
	runRegexTrial(t, `a$`, Multiline, "a\nb\n", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a\Z`, Multiline, "b\na\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\z`, Multiline, "b\na\n", "Fail.")
	runRegexTrial(t, `a$`, Multiline, "b\na\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\Z`, Multiline, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a\z`, Multiline, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `a$`, Multiline, "b\na", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `aa\Z`, 0, "aa\nb\n", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "aa\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "aa\nb\n", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "b\naa\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\z`, 0, "b\naa\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "b\naa\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\Z`, 0, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\z`, 0, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa$`, 0, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\z`, Multiline, "aa\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "aa\nb\n", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `aa\Z`, Multiline, "b\naa\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\z`, Multiline, "b\naa\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "b\naa\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\Z`, Multiline, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\z`, Multiline, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa$`, Multiline, "b\naa", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `aa\Z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `aa$`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa$`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa\Z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `aa\z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `aa$`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `aa\Z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `aa\z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `aa$`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "ab\nb\n", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "ab\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "ab\nb\n", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "b\nab\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\z`, 0, "b\nab\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "b\nab\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\Z`, 0, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\z`, 0, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab$`, 0, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\z`, Multiline, "ab\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "ab\nb\n", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nab\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\z`, Multiline, "b\nab\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "b\nab\n", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\z`, Multiline, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab$`, Multiline, "b\nab", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `ab\Z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `ab$`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab$`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab\Z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `ab\z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `ab$`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `ab\Z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `ab\z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `ab$`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "abb\nb\n", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "abb\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "abb\nb\n", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "b\nabb\n", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\z`, 0, "b\nabb\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "b\nabb\n", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\Z`, 0, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\z`, 0, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb$`, 0, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\z`, Multiline, "abb\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "abb\nb\n", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nabb\n", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\z`, Multiline, "b\nabb\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "b\nabb\n", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\z`, Multiline, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb$`, Multiline, "b\nabb", "Pass. Group[0]=(2,3)")
	runRegexTrial(t, `abb\Z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `abb$`, 0, "b\nac", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "ac\nb\n", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "b\nac\n", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "b\nac", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb$`, 0, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb\Z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `abb\z`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `abb$`, 0, "b\nca", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "ca\nb\n", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "b\nca\n", "Fail.")
	runRegexTrial(t, `abb\Z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `abb\z`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `abb$`, Multiline, "b\nca", "Fail.")
	runRegexTrial(t, `(^|x)(c)`, 0, "ca", "Pass. Group[0]=(0,1) Group[1]=(0,0) Group[2]=(0,1)")
	runRegexTrial(t, `a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz`, 0, "x", "Fail.")
	runRegexTrial(t, `round\(((?>[^()]+))\)`, 0, "_I(round(xs * sz),1)", "Pass. Group[0]=(3,14) Group[1]=(9,7)")
	runRegexTrial(t, `foo.bart`, 0, "foo.bart", "Pass. Group[0]=(0,8)")
	runRegexTrial(t, `^d[x][x][x]`, Multiline, "abcd\ndxxx", "Pass. Group[0]=(5,4)")
	runRegexTrial(t, `.X(.+)+X`, 0, "bbbbXcXaaaaaaaa", "Pass. Group[0]=(3,4) Group[1]=(5,1)")
	runRegexTrial(t, `.X(.+)+XX`, 0, "bbbbXcXXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(5,1)")
	runRegexTrial(t, `.XX(.+)+X`, 0, "bbbbXXcXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(6,1)")
	runRegexTrial(t, `.X(.+)+X`, 0, "bbbbXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.X(.+)+XX`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.XX(.+)+X`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.X(.+)+[X]`, 0, "bbbbXcXaaaaaaaa", "Pass. Group[0]=(3,4) Group[1]=(5,1)")
	runRegexTrial(t, `.X(.+)+[X][X]`, 0, "bbbbXcXXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(5,1)")
	runRegexTrial(t, `.XX(.+)+[X]`, 0, "bbbbXXcXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(6,1)")
	runRegexTrial(t, `.X(.+)+[X]`, 0, "bbbbXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.X(.+)+[X][X]`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.XX(.+)+[X]`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.[X](.+)+[X]`, 0, "bbbbXcXaaaaaaaa", "Pass. Group[0]=(3,4) Group[1]=(5,1)")
	runRegexTrial(t, `.[X](.+)+[X][X]`, 0, "bbbbXcXXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(5,1)")
	runRegexTrial(t, `.[X][X](.+)+[X]`, 0, "bbbbXXcXaaaaaaaa", "Pass. Group[0]=(3,5) Group[1]=(6,1)")
	runRegexTrial(t, `.[X](.+)+[X]`, 0, "bbbbXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.[X](.+)+[X][X]`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `.[X][X](.+)+[X]`, 0, "bbbbXXXaaaaaaaaa", "Fail.")
	runRegexTrial(t, `tt+$`, 0, "xxxtt", "Pass. Group[0]=(3,2)")
	runRegexTrial(t, `([\d-z]+)`, 0, "a0-za", "Pass. Group[0]=(1,3) Group[1]=(1,3)")
	runRegexTrial(t, `([\d-\s]+)`, 0, "a0- z", "Pass. Group[0]=(1,3) Group[1]=(1,3)")
	runRegexTrial(t, `\GX.*X`, 0, "aaaXbX", "Fail.")
	runRegexTrial(t, `(\d+\.\d+)`, 0, "3.1415926", "Pass. Group[0]=(0,9) Group[1]=(0,9)")
	runRegexTrial(t, `(\ba.{0,10}br)`, 0, "have a web browser", "Pass. Group[0]=(5,8) Group[1]=(5,8)")
	runRegexTrial(t, `\.c(pp|xx|c)?$`, IgnoreCase, "Changes", "Fail.")
	runRegexTrial(t, `\.c(pp|xx|c)?$`, IgnoreCase, "IO.c", "Pass. Group[0]=(2,2) Group[1]=")
	runRegexTrial(t, `(\.c(pp|xx|c)?$)`, IgnoreCase, "IO.c", "Pass. Group[0]=(2,2) Group[1]=(2,2) Group[2]=")
	runRegexTrial(t, `^([a-z]:)`, 0, "C:/", "Fail.")
	runRegexTrial(t, `^\S\s+aa$`, Multiline, "\nx aa", "Pass. Group[0]=(1,4)")
	runRegexTrial(t, `(^|a)b`, 0, "ab", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `^([ab]*?)(b)?(c)$`, 0, "abac", "Pass. Group[0]=(0,4) Group[1]=(0,3) Group[2]= Group[3]=(3,1)")
	runRegexTrial(t, `(\w)?(abc)\1b`, 0, "abcab", "Fail.")
	runRegexTrial(t, `^(?:.,){2}c`, 0, "a,b,c", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `^(.,){2}c`, 0, "a,b,c", "Pass. Group[0]=(0,5) Group[1]=(0,2)(2,2)")
	runRegexTrial(t, `^(?:[^,]*,){2}c`, 0, "a,b,c", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `^([^,]*,){2}c`, 0, "a,b,c", "Pass. Group[0]=(0,5) Group[1]=(0,2)(2,2)")
	runRegexTrial(t, `^([^,]*,){3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]*,){3,}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]*,){0,3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,3},){3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,3},){3,}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,3},){0,3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,},){3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,},){3,}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{1,},){0,3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{0,3},){3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{0,3},){3,}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `^([^,]{0,3},){0,3}d`, 0, "aaa,b,c,d", "Pass. Group[0]=(0,9) Group[1]=(0,4)(4,2)(6,2)")
	runRegexTrial(t, `(?i)`, 0, "", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `(?!\A)x`, Multiline, "a\nxb\n", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `^(a(b)?)+$`, 0, "aba", "Pass. Group[0]=(0,3) Group[1]=(0,2)(2,1) Group[2]=(1,1)")
	runRegexTrial(t, `^(aa(bb)?)+$`, 0, "aabbaa", "Pass. Group[0]=(0,6) Group[1]=(0,4)(4,2) Group[2]=(2,2)")
	runRegexTrial(t, `^.{9}abc.*\n`, Multiline, "123\nabcabcabcabc\n", "Pass. Group[0]=(4,13)")
	runRegexTrial(t, `^(a)?a$`, 0, "a", "Pass. Group[0]=(0,1) Group[1]=")
	runRegexTrial(t, `^(a)?(?(1)a|b)+$`, 0, "a", "Fail.")
	runRegexTrial(t, `^(a\1?)(a\1?)(a\2?)(a\3?)$`, 0, "aaaaaa", "Pass. Group[0]=(0,6) Group[1]=(0,1) Group[2]=(1,2) Group[3]=(3,1) Group[4]=(4,2)")
	runRegexTrial(t, `^(a\1?){4}$`, 0, "aaaaaa", "Pass. Group[0]=(0,6) Group[1]=(0,1)(1,2)(3,1)(4,2)")
	runRegexTrial(t, `^(0+)?(?:x(1))?`, 0, "x1", "Pass. Group[0]=(0,2) Group[1]= Group[2]=(1,1)")
	runRegexTrial(t, `^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?`, 0, "012cxx0190", "Pass. Group[0]=(0,10) Group[1]=(0,4) Group[2]= Group[3]=(6,4)")
	runRegexTrial(t, `^(b+?|a){1,2}c`, 0, "bbbac", "Pass. Group[0]=(0,5) Group[1]=(0,3)(3,1)")
	runRegexTrial(t, `^(b+?|a){1,2}c`, 0, "bbbbac", "Pass. Group[0]=(0,6) Group[1]=(0,4)(4,1)")
	runRegexTrial(t, `\((\w\. \w+)\)`, 0, "cd. (A. Tw)", "Pass. Group[0]=(4,7) Group[1]=(5,5)")
	runRegexTrial(t, `((?:aaaa|bbbb)cccc)?`, 0, "aaaacccc", "Pass. Group[0]=(0,8) Group[1]=(0,8)")
	runRegexTrial(t, `((?:aaaa|bbbb)cccc)?`, 0, "bbbbcccc", "Pass. Group[0]=(0,8) Group[1]=(0,8)")

	runRegexTrial(t, `^(foo)|(bar)$`, 0, "foobar", "Pass. Group[0]=(0,3) Group[1]=(0,3) Group[2]=")
	runRegexTrial(t, `^(foo)|(bar)$`, RightToLeft, "foobar", "Pass. Group[0]=(3,3) Group[1]= Group[2]=(3,3)")

	runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")
	runRegexTrial(t, `bab`, RightToLeft, "babababaa", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `abb`, RightToLeft, "abb", "Pass. Group[0]=(0,3)")

	runRegexTrial(t, `b$`, RightToLeft|Multiline, "aab\naab", "Pass. Group[0]=(6,1)")
	runRegexTrial(t, `^a`, RightToLeft|Multiline, "aab\naab", "Pass. Group[0]=(4,1)")
	runRegexTrial(t, `^aaab`, RightToLeft|Multiline, "aaab\naab", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `abb{2}`, RightToLeft, "abbb", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `abb{1,2}`, RightToLeft, "abbb", "Pass. Group[0]=(0,4)")

	runRegexTrial(t, `abb{1,2}`, RightToLeft, "abbbbbaaaa", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `\Ab`, RightToLeft, "bab\naaa", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\Abab$`, RightToLeft, "bab", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `b\Z`, RightToLeft, "bab\naaa", "Fail.")
	runRegexTrial(t, `b\Z`, RightToLeft, "babaaab", "Pass. Group[0]=(6,1)")
	runRegexTrial(t, `b\z`, RightToLeft, "babaaa", "Fail.")
	runRegexTrial(t, `b\z`, RightToLeft, "babaaab", "Pass. Group[0]=(6,1)")
	runRegexTrial(t, `a\G`, RightToLeft, "babaaa", "Pass. Group[0]=(5,1)")
	runRegexTrial(t, `\Abaaa\G`, RightToLeft, "baaa", "Pass. Group[0]=(0,4)")
	//			runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")
	//			runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")
	//			runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")
	//			runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")

	runRegexTrial(t, `\bc`, RightToLeft, "aaa c aaa c a", "Pass. Group[0]=(10,1)")
	runRegexTrial(t, `\bc`, RightToLeft, "c aaa c", "Pass. Group[0]=(6,1)")
	runRegexTrial(t, `\bc`, RightToLeft, "aaa ac", "Fail.")
	runRegexTrial(t, `\bc`, RightToLeft, "c aaa", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\bc`, RightToLeft, "aaacaaa", "Fail.")
	runRegexTrial(t, `\bc`, RightToLeft, "aaac aaa", "Fail.")
	runRegexTrial(t, `\bc`, RightToLeft, "aaa ca caaa", "Pass. Group[0]=(7,1)")

	runRegexTrial(t, `\Bc`, RightToLeft, "ac aaa ac", "Pass. Group[0]=(8,1)")
	runRegexTrial(t, `\Bc`, RightToLeft, "aaa c", "Fail.")
	runRegexTrial(t, `\Bc`, RightToLeft, "ca aaa", "Fail.")
	runRegexTrial(t, `\Bc`, RightToLeft, "aaa c aaa", "Fail.")
	runRegexTrial(t, `\Bc`, RightToLeft, " acaca ", "Pass. Group[0]=(4,1)")
	runRegexTrial(t, `\Bc`, RightToLeft, "aaac aaac", "Pass. Group[0]=(8,1)")
	runRegexTrial(t, `\Bc`, RightToLeft, "aaa caaa", "Fail.")

	runRegexTrial(t, `b(a?)b`, RightToLeft, "aabababbaaababa", "Pass. Group[0]=(11,3) Group[1]=(12,1)")
	runRegexTrial(t, `b{4}`, RightToLeft, "abbbbaabbbbaabbb", "Pass. Group[0]=(7,4)")
	runRegexTrial(t, `b\1aa(.)`, RightToLeft, "bBaaB", "Pass. Group[0]=(0,5) Group[1]=(4,1)")
	runRegexTrial(t, `b(.)aa\1`, RightToLeft, "bBaaB", "Fail.")

	runRegexTrial(t, `^(a\1?){4}$`, RightToLeft, "aaaaaa", "Pass. Group[0]=(0,6) Group[1]=(5,1)(3,2)(2,1)(0,2)")
	runRegexTrial(t, `^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?`, RightToLeft, "012cxx0190", "Pass. Group[0]=(0,10) Group[1]=(0,4) Group[2]= Group[3]=(6,4)")
	runRegexTrial(t, `^(b+?|a){1,2}c`, RightToLeft, "bbbac", "Pass. Group[0]=(0,5) Group[1]=(3,1)(0,3)")
	runRegexTrial(t, `\((\w\. \w+)\)`, RightToLeft, "cd. (A. Tw)", "Pass. Group[0]=(4,7) Group[1]=(5,5)")
	runRegexTrial(t, `((?:aaaa|bbbb)cccc)?`, RightToLeft, "aaaacccc", "Pass. Group[0]=(0,8) Group[1]=(0,8)")
	runRegexTrial(t, `((?:aaaa|bbbb)cccc)?`, RightToLeft, "bbbbcccc", "Pass. Group[0]=(0,8) Group[1]=(0,8)")

	runRegexTrial(t, `(?<=a)b`, RightToLeft, "ab", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(?<=a)b`, RightToLeft, "cb", "Fail.")
	runRegexTrial(t, `(?<=a)b`, RightToLeft, "b", "Fail.")
	runRegexTrial(t, `(?<!c)b`, RightToLeft, "ab", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `(?<!c)b`, RightToLeft, "cb", "Fail.")
	runRegexTrial(t, `(?<!c)b`, RightToLeft, "b", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(?<!c)b`, RightToLeft, "b", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a(?=d).`, RightToLeft, "adabad", "Pass. Group[0]=(4,2)")
	runRegexTrial(t, `a(?=c|d).`, RightToLeft, "adabad", "Pass. Group[0]=(4,2)")

	runRegexTrial(t, `ab*c`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab*bc`, RightToLeft, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab*bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `.{1}`, RightToLeft, "abbbbc", "Pass. Group[0]=(5,1)")
	runRegexTrial(t, `.{3,4}`, RightToLeft, "abbbbc", "Pass. Group[0]=(2,4)")
	runRegexTrial(t, `ab{0,}bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab+bc`, RightToLeft, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab+bc`, RightToLeft, "abc", "Fail.")
	runRegexTrial(t, `ab+bc`, RightToLeft, "abq", "Fail.")
	runRegexTrial(t, `ab{1,}bc`, RightToLeft, "abq", "Fail.")
	runRegexTrial(t, `ab+bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,}bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{1,3}bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{3,4}bc`, RightToLeft, "abbbbc", "Pass. Group[0]=(0,6)")
	runRegexTrial(t, `ab{4,5}bc`, RightToLeft, "abbbbc", "Fail.")
	runRegexTrial(t, `ab?bc`, RightToLeft, "abbc", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `ab?bc`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}bc`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab?bc`, RightToLeft, "abbbbc", "Fail.")
	runRegexTrial(t, `ab?c`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `ab{0,1}c`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, RightToLeft, "abcc", "Fail.")
	runRegexTrial(t, `^abc`, RightToLeft, "abcc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^abc$`, RightToLeft, "aabc", "Fail.")
	runRegexTrial(t, `abc$`, RightToLeft, "aabc", "Pass. Group[0]=(1,3)")
	runRegexTrial(t, `abc$`, RightToLeft, "aabcd", "Fail.")
	runRegexTrial(t, `^`, RightToLeft, "abc", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `$`, RightToLeft, "abc", "Pass. Group[0]=(3,0)")
	runRegexTrial(t, `a.c`, RightToLeft, "abc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.c`, RightToLeft, "axc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a.*c`, RightToLeft, "axyzc", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `a.*c`, RightToLeft, "axyzd", "Fail.")
	runRegexTrial(t, `a[bc]d`, RightToLeft, "abc", "Fail.")
	runRegexTrial(t, `a[bc]d`, RightToLeft, "abd", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]e`, RightToLeft, "abd", "Fail.")
	runRegexTrial(t, `a[b-d]e`, RightToLeft, "ace", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[b-d]`, RightToLeft, "aac", "Pass. Group[0]=(1,2)")
	runRegexTrial(t, `a[-b]`, RightToLeft, "a-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-]`, RightToLeft, "a-", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[b-a]`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `a[]b`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `a[`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `a]`, RightToLeft, "a]", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a[]]b`, RightToLeft, "a]b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, RightToLeft, "aed", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^bc]d`, RightToLeft, "abd", "Fail.")
	runRegexTrial(t, `a[^-b]c`, RightToLeft, "adc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[^-b]c`, RightToLeft, "a-c", "Fail.")
	runRegexTrial(t, `a[^]b]c`, RightToLeft, "a]c", "Fail.")
	runRegexTrial(t, `a[^]b]c`, RightToLeft, "adc", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `\ba\b`, RightToLeft, "a-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\ba\b`, RightToLeft, "-a", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\ba\b`, RightToLeft, "-a-", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\by\b`, RightToLeft, "xy", "Fail.")
	runRegexTrial(t, `\by\b`, RightToLeft, "yz", "Fail.")
	runRegexTrial(t, `\by\b`, RightToLeft, "xyz", "Fail.")
	runRegexTrial(t, `\Ba\B`, RightToLeft, "a-", "Fail.")
	runRegexTrial(t, `\Ba\B`, RightToLeft, "-a", "Fail.")
	runRegexTrial(t, `\Ba\B`, RightToLeft, "-a-", "Fail.")
	runRegexTrial(t, `\By\b`, RightToLeft, "xy", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\by\B`, RightToLeft, "yz", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\By\B`, RightToLeft, "xyz", "Pass. Group[0]=(1,1)")
	runRegexTrial(t, `\w`, RightToLeft, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\w`, RightToLeft, "-", "Fail.")
	runRegexTrial(t, `\W`, RightToLeft, "a", "Fail.")
	runRegexTrial(t, `\W`, RightToLeft, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a\sb`, RightToLeft, "a b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a\sb`, RightToLeft, "a-b", "Fail.")
	runRegexTrial(t, `a\Sb`, RightToLeft, "a b", "Fail.")
	runRegexTrial(t, `a\Sb`, RightToLeft, "a-b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `\d`, RightToLeft, "1", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `\d`, RightToLeft, "-", "Fail.")
	runRegexTrial(t, `\D`, RightToLeft, "1", "Fail.")
	runRegexTrial(t, `\D`, RightToLeft, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\w]`, RightToLeft, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\w]`, RightToLeft, "-", "Fail.")
	runRegexTrial(t, `[\W]`, RightToLeft, "a", "Fail.")
	runRegexTrial(t, `[\W]`, RightToLeft, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `a[\s]b`, RightToLeft, "a b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a[\s]b`, RightToLeft, "a-b", "Fail.")
	runRegexTrial(t, `a[\S]b`, RightToLeft, "a b", "Fail.")
	runRegexTrial(t, `a[\S]b`, RightToLeft, "a-b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `[\d]`, RightToLeft, "1", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `[\d]`, RightToLeft, "-", "Fail.")
	runRegexTrial(t, `[\D]`, RightToLeft, "1", "Fail.")
	runRegexTrial(t, `[\D]`, RightToLeft, "-", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `ab|cd`, RightToLeft, "abc", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `ab|cd`, RightToLeft, "abcd", "Pass. Group[0]=(2,2)")
	runRegexTrial(t, `()ef`, RightToLeft, "def", "Pass. Group[0]=(1,2) Group[1]=(1,0)")
	runRegexTrial(t, `*a`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `(*)b`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `$b`, RightToLeft, "b", "Fail.")
	runRegexTrial(t, `a\`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `a\(b`, RightToLeft, "a(b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `a\(*b`, RightToLeft, "ab", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `a\(*b`, RightToLeft, "a((b", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a\\b`, RightToLeft, "a\\b", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc)`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `(abc`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `((a))`, RightToLeft, "abc", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1)")
	runRegexTrial(t, `(a)b(c)`, RightToLeft, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(2,1)")
	runRegexTrial(t, `a+b+c`, RightToLeft, "aabbabc", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a{1,}b{1,}c`, RightToLeft, "aabbabc", "Pass. Group[0]=(4,3)")
	runRegexTrial(t, `a**`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `a.+?c`, RightToLeft, "abcabc", "Pass. Group[0]=(3,3)")
	runRegexTrial(t, `(a+|b)*`, RightToLeft, "ab", "Pass. Group[0]=(0,2) Group[1]=(1,1)(0,1)")
	runRegexTrial(t, `(a+|b){0,}`, RightToLeft, "ab", "Pass. Group[0]=(0,2) Group[1]=(1,1)(0,1)")
	runRegexTrial(t, `(a+|b)+`, RightToLeft, "ab", "Pass. Group[0]=(0,2) Group[1]=(1,1)(0,1)")
	runRegexTrial(t, `(a+|b){1,}`, RightToLeft, "ab", "Pass. Group[0]=(0,2) Group[1]=(1,1)(0,1)")
	runRegexTrial(t, `(a+|b)?`, RightToLeft, "ab", "Pass. Group[0]=(1,1) Group[1]=(1,1)")
	runRegexTrial(t, `(a+|b){0,1}`, RightToLeft, "ab", "Pass. Group[0]=(1,1) Group[1]=(1,1)")
	runRegexTrial(t, `)(`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `[^ab]*`, RightToLeft, "cde", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `abc`, RightToLeft, "", "Fail.")
	runRegexTrial(t, `a*`, RightToLeft, "", "Pass. Group[0]=(0,0)")
	runRegexTrial(t, `([abc])*d`, RightToLeft, "abbbcd", "Pass. Group[0]=(0,6) Group[1]=(4,1)(3,1)(2,1)(1,1)(0,1)")
	runRegexTrial(t, `([abc])*bcd`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(0,1)")
	runRegexTrial(t, `a|b|c|d|e`, RightToLeft, "e", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `(a|b|c|d|e)f`, RightToLeft, "ef", "Pass. Group[0]=(0,2) Group[1]=(0,1)")
	runRegexTrial(t, `abcd*efg`, RightToLeft, "abcdefg", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `ab*`, RightToLeft, "xabyabbbz", "Pass. Group[0]=(4,4)")
	runRegexTrial(t, `ab*`, RightToLeft, "xayabbbz", "Pass. Group[0]=(3,4)")
	runRegexTrial(t, `(ab|cd)e`, RightToLeft, "abcde", "Pass. Group[0]=(2,3) Group[1]=(2,2)")
	runRegexTrial(t, `[abhgefdc]ij`, RightToLeft, "hij", "Pass. Group[0]=(0,3)")
	runRegexTrial(t, `^(ab|cd)e`, RightToLeft, "abcde", "Fail.")
	runRegexTrial(t, `(abc|)ef`, RightToLeft, "abcdef", "Pass. Group[0]=(4,2) Group[1]=(4,0)")
	runRegexTrial(t, `(a|b)c*d`, RightToLeft, "abcd", "Pass. Group[0]=(1,3) Group[1]=(1,1)")
	runRegexTrial(t, `(ab|ab*)bc`, RightToLeft, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,1)")
	runRegexTrial(t, `a([bc]*)c*`, RightToLeft, "abc", "Pass. Group[0]=(0,3) Group[1]=(1,1)")
	runRegexTrial(t, `a([bc]*)(c*d)`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,1) Group[2]=(2,2)")
	runRegexTrial(t, `a([bc]+)(c*d)`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,1) Group[2]=(2,2)")
	runRegexTrial(t, `a([bc]*)(c+d)`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,1) Group[2]=(2,2)")
	runRegexTrial(t, `a[bcd]*dcdcde`, RightToLeft, "adcdcde", "Pass. Group[0]=(0,7)")
	runRegexTrial(t, `a[bcd]+dcdcde`, RightToLeft, "adcdcde", "Fail.")
	runRegexTrial(t, `(ab|a)b*c`, RightToLeft, "abc", "Pass. Group[0]=(0,3) Group[1]=(0,1)")
	runRegexTrial(t, `((a)(b)c)(d)`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(0,3) Group[2]=(0,1) Group[3]=(1,1) Group[4]=(3,1)")
	runRegexTrial(t, `[a-zA-Z_][a-zA-Z0-9_]*`, RightToLeft, "alpha", "Pass. Group[0]=(0,5)")
	runRegexTrial(t, `^a(bc+|b[eh])g|.h$`, RightToLeft, "abh", "Pass. Group[0]=(1,2) Group[1]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, RightToLeft, "effgz", "Pass. Group[0]=(0,5) Group[1]=(0,5) Group[2]=")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, RightToLeft, "ij", "Pass. Group[0]=(0,2) Group[1]=(0,2) Group[2]=(1,1)")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, RightToLeft, "effg", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, RightToLeft, "bcdd", "Fail.")
	runRegexTrial(t, `(bc+d$|ef*g.|h?i(j|k))`, RightToLeft, "reffgz", "Pass. Group[0]=(1,5) Group[1]=(1,5) Group[2]=")
	runRegexTrial(t, `((((((((((a))))))))))`, RightToLeft, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `((((((((((a))))))))))\10`, RightToLeft, "aa", "Fail.")
	runRegexTrial(t, `\10((((((((((a))))))))))`, RightToLeft, "aa", "Pass. Group[0]=(0,2) Group[1]=(1,1) Group[2]=(1,1) Group[3]=(1,1) Group[4]=(1,1) Group[5]=(1,1) Group[6]=(1,1) Group[7]=(1,1) Group[8]=(1,1) Group[9]=(1,1) Group[10]=(1,1)")
	runRegexTrial(t, `((((((((((a))))))))))!`, RightToLeft, "aa", "Fail.")
	runRegexTrial(t, `((((((((((a))))))))))!`, RightToLeft, "a!", "Pass. Group[0]=(0,2) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1) Group[10]=(0,1)")
	runRegexTrial(t, `(((((((((a)))))))))`, RightToLeft, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1) Group[2]=(0,1) Group[3]=(0,1) Group[4]=(0,1) Group[5]=(0,1) Group[6]=(0,1) Group[7]=(0,1) Group[8]=(0,1) Group[9]=(0,1)")
	runRegexTrial(t, `multiple words of text`, RightToLeft, "uh-uh", "Fail.")
	runRegexTrial(t, `multiple words`, RightToLeft, "multiple words, yeah", "Pass. Group[0]=(0,14)")
	runRegexTrial(t, `(.*)c(.*)`, RightToLeft, "abcde", "Pass. Group[0]=(0,5) Group[1]=(0,2) Group[2]=(3,2)")
	runRegexTrial(t, `\((.*), (.*)\)`, RightToLeft, "(a, b)", "Pass. Group[0]=(0,6) Group[1]=(1,1) Group[2]=(4,1)")
	runRegexTrial(t, `[k]`, RightToLeft, "ab", "Fail.")
	runRegexTrial(t, `abcd`, RightToLeft, "abcd", "Pass. Group[0]=(0,4)")
	runRegexTrial(t, `a(bc)d`, RightToLeft, "abcd", "Pass. Group[0]=(0,4) Group[1]=(1,2)")
	runRegexTrial(t, `a[-]?c`, RightToLeft, "ac", "Pass. Group[0]=(0,2)")
	runRegexTrial(t, `(abc)\1`, RightToLeft, "abcabc", "Fail.")
	runRegexTrial(t, `\1(abc)`, RightToLeft, "abcabc", "Pass. Group[0]=(0,6) Group[1]=(3,3)")
	runRegexTrial(t, `([a-c]*)\1`, RightToLeft, "abcabc", "Fail.")
	runRegexTrial(t, `\1([a-c]*)`, RightToLeft, "abcabc", "Pass. Group[0]=(0,6) Group[1]=(3,3)")
	runRegexTrial(t, `\1`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `\2`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `(a)|\1`, RightToLeft, "a", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `(a)|\1`, RightToLeft, "x", "Fail.")
	runRegexTrial(t, `(a)|\2`, RightToLeft, "-", "Error.")
	runRegexTrial(t, `(([a-c])b*?\2)*`, RightToLeft, "ababbbcbc", "Pass. Group[0]=(9,0) Group[1]= Group[2]=")
	runRegexTrial(t, `(([a-c])b*?\2){3}`, RightToLeft, "ababbbcbc", "Fail.")
	runRegexTrial(t, `((\3|b)\2(a)x)+`, RightToLeft, "aaxabxbaxbbx", "Fail.")
	runRegexTrial(t, `((\3|b)\2(a)x)+`, RightToLeft, "aaaxabaxbaaxbbax", "Fail.")
	runRegexTrial(t, `((\3|b)\2(a)){2,}`, RightToLeft, "bbaababbabaaaaabbaaaabba", "Fail.")

	runRegexTrial(t, `\((?>[^()]+|\((?<depth>)|\)(?<-depth>))*(?(depth)(?!))\)`, 0, "((a(b))c)", "Pass. Group[0]=(0,9) Group[1]=")
	runRegexTrial(t, `^\((?>[^()]+|\((?<depth>)|\)(?<-depth>))*(?(depth)(?!))\)$`, 0, "((a(b))c)", "Pass. Group[0]=(0,9) Group[1]=")
	runRegexTrial(t, `^\((?>[^()]+|\((?<depth>)|\)(?<-depth>))*(?(depth)(?!))\)$`, 0, "((a(b))c", "Fail.")

	runRegexTrial(t, `^\((?>[^()]+|\((?<depth>)|\)(?<-depth>))*(?(depth)(?!))\)$`, 0, "())", "Fail.")

	runRegexTrial(t, `(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))`, 0, "((a(b))c)",
		"Pass. Group[0]=(0,9) Group[1]=(0,9) Group[2]=(0,1)(1,2)(3,2) Group[3]=(5,1)(6,2)(8,1) Group[4]= Group[5]=(4,1)(2,4)(1,7)")
	runRegexTrial(t, `^(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))$`, 0, "((a(b))c)",
		"Pass. Group[0]=(0,9) Group[1]=(0,9) Group[2]=(0,1)(1,2)(3,2) Group[3]=(5,1)(6,2)(8,1) Group[4]= Group[5]=(4,1)(2,4)(1,7)")
	runRegexTrial(t, `(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))`, 0, "x(a((b)))b)x",
		"Pass. Group[0]=(1,9) Group[1]=(1,9) Group[2]=(1,2)(3,1)(4,2) Group[3]=(6,1)(7,1)(8,2) Group[4]= Group[5]=(5,1)(4,3)(2,6)")
	runRegexTrial(t, `(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))`, 0, "x((a((b)))x",
		"Pass. Group[0]=(2,9) Group[1]=(2,9) Group[2]=(2,2)(4,1)(5,2) Group[3]=(7,1)(8,1)(9,2) Group[4]= Group[5]=(6,1)(5,3)(3,6)")
	runRegexTrial(t, `^(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))$`, 0, "((a(b))c", "Fail.")
	runRegexTrial(t, `^(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))$`, 0, "((a(b))c))", "Fail.")
	runRegexTrial(t, `^(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))$`, 0, ")(", "Fail.")
	runRegexTrial(t, `^(((?<foo>\()[^()]*)+((?<bar-foo>\))[^()]*)+)+(?(foo)(?!))$`, 0, "((a((b))c)", "Fail.")

	runRegexTrial(t, `b`, RightToLeft, "babaaa", "Pass. Group[0]=(2,1)")

	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[n]", "Pass. Group[0]=(0,3) Group[1]=(1,1)")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "n", "Pass. Group[0]=(0,1) Group[1]=(0,1)")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "n[i]e", "Fail.")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[n", "Fail.")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "]n]", "Fail.")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, `\[n\]`, "Fail.")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, `[n\]`, "Pass. Group[0]=(0,4) Group[1]=(1,2)")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, `[n\[]`, "Pass. Group[0]=(0,5) Group[1]=(1,3)")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, `[[n]`, "Pass. Group[0]=(0,4) Group[1]=(1,2)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[s] . [n]", "Pass. Group[0]=(0,9) Group[1]=(1,1) Group[2]=(7,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[s] . n", "Pass. Group[0]=(0,7) Group[1]=(1,1) Group[2]=(6,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "s.[ n ]", "Pass. Group[0]=(0,7) Group[1]=(0,1) Group[2]=(3,3)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, " . n", "Pass. Group[0]=(0,4) Group[1]=(0,1) Group[2]=(3,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "s. ", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(2,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[.]. ", "Pass. Group[0]=(0,5) Group[1]=(1,1) Group[2]=(4,1)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[c].[s].[n]", "Pass. Group[0]=(0,11) Group[1]=(1,1) Group[2]=(5,1) Group[3]=(9,1)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, " c . s . n ", "Pass. Group[0]=(0,11) Group[1]=(0,3) Group[2]=(5,2) Group[3]=(9,2)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, " . [.] . [ ]", "Pass. Group[0]=(0,12) Group[1]=(0,1) Group[2]=(4,1) Group[3]=(10,1)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "c.n", "Pass. Group[0]=(0,3) Group[1]=(0,1) Group[2]=(2,1)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[c] .[n]", "Pass. Group[0]=(0,8) Group[1]=(1,1) Group[2]=(6,1)")
	runRegexTrial(t, `^((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "c.n.", "Fail.")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "s.c.n", "Pass. Group[0]=(0,5) Group[1]=(0,1) Group[2]=(2,1) Group[3]=(4,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[s].[c].[n]", "Pass. Group[0]=(0,11) Group[1]=(1,1) Group[2]=(5,1) Group[3]=(9,1)")
	runRegexTrial(t, `^((\[(?<SCHEMA>[^\]]+)\])|(?<SCHEMA>[^\.\[\]]+))\s*\.\s*((\[(?<CATALOG>[^\]]+)\])|(?<CATALOG>[^\.\[\]]+))\s*\.\s*((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, Compiled|IgnoreCase|ExplicitCapture, "[s].[c].", "Fail.")
	runRegexTrial(t, `^((\[(?<ColName>.+)\])|(?<ColName>\S+))([ ]+(?<Order>ASC|DESC))?$`, IgnoreCase|ExplicitCapture, "[id]]", "Pass. Group[0]=(0,5) Group[1]=(1,3) Group[2]=")
	runRegexTrial(t, `a{1,2147483647}`, 0, "a", "Pass. Group[0]=(0,1)")
	runRegexTrial(t, `^((\[(?<NAME>[^\]]+)\])|(?<NAME>[^\.\[\]]+))$`, 0, "[a]", "Pass. Group[0]=(0,3) Group[1]=(0,3) Group[2]=(0,3) Group[3]=(1,1)")

}

func runRegexTrial(t *testing.T, pattern string, options RegexOptions, input, expected string) {
	result := ""

	re, err := Compile(pattern, options)
	if err != nil {
		if expected != "Error." {
			t.Errorf("Compiling pattern '%v' with options '%v' -- expected '%v' got '%v'", pattern, options, expected, err.Error())
		}
		return
	}

	groupNums := re.GetGroupNumbers()
	m, err := re.FindStringMatch(input)
	if err != nil {
		result = fmt.Sprintf("Error. %v", err.Error())
	} else if m != nil {
		result = "Pass."
		for i, group := range m.Groups() {
			gid := groupNums[i]

			result += fmt.Sprintf(" Group[%v]=", gid)
			for _, cp := range group.Captures {
				result += fmt.Sprintf("(%v,%v)", cp.Index, cp.Length)
			}
		}
	} else {
		result = "Fail."
	}

	if expected != result {
		t.Errorf("Matching input '%v' against pattern '%v' with options '%v' -- expected '%v' got '%v'", input, pattern, options, expected, result)
	}
}