📄 tests.txt
字号:
; ; ; this file contains a script of tests to run through regress.exe;; comments start with a semicolon and proceed to the end of the line;; changes to regular expression compile flags start with a "-" as the first; non-whitespace character and consist of a list of the printable names; of the flags, for example "match_default";; Other lines contain a test to perform using the current flag status; the first token contains the expression to compile, the second the string; to match it against. If the second string is "!" then the expression should; not compile, that is the first string is an invalid regular expression.; This is then followed by a list of integers that specify what should match,; each pair represents the starting and ending positions of a subexpression; starting with the zeroth subexpression (the whole match).; A value of -1 indicates that the subexpression should not take part in the; match at all, if the first value is -1 then no part of the expression should; match the string.;- match_default normal REG_EXTENDED;; try some really simple literals:a a 0 1Z Z 0 1Z aaa -1 -1Z xxxxZZxxx 4 5; and some simple brackets:(a) zzzaazz 3 4 3 4() zzz 0 0 0 0() "" 0 0 0 0( !) !(aa !aa) !a b -1 -1\(\) () 0 2\(a\) (a) 0 3\() !(\) !p(a)rameter ABCparameterXYZ 3 12 4 5[pq](a)rameter ABCparameterXYZ 3 12 4 5; now try escaped brackets:- match_default bk_parens REG_BASIC\(a\) zzzaazz 3 4 3 4\(\) zzz 0 0 0 0\(\) "" 0 0 0 0\( !\) !\(aa !aa\) !() () 0 2(a) (a) 0 3(\) !\() !; now move on to "." wildcards- match_default normal REG_EXTENDED REG_STARTEND. a 0 1. \n 0 1. \r 0 1. \0 0 1- match_default normal match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE. a 0 1. \n -1 -1. \r -1 -1. \0 0 1- match_default normal match_not_dot_null match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE. \n -1 -1. \r -1 -1; this *WILL* produce an error from the POSIX API functions:- match_default normal match_not_dot_null match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE REG_NO_POSIX_TEST. \0 -1 -1;; now move on to the repetion ops,; starting with operator *- match_default normal REG_EXTENDEDa* b 0 0ab* a 0 1ab* ab 0 2ab* sssabbbbbbsss 3 10ab*c* a 0 1ab*c* abbb 0 4ab*c* accc 0 4ab*c* abbcc 0 5*a !\<* !\>* !\n* \n\n 0 2\** ** 0 2\* * 0 1; now try operator +ab+ a -1 -1ab+ ab 0 2ab+ sssabbbbbbsss 3 10ab+c+ a -1 -1ab+c+ abbb -1 -1ab+c+ accc -1 -1ab+c+ abbcc 0 5+a !\<+ !\>+ !\n+ \n\n 0 2\+ + 0 1\+ ++ 0 1\++ ++ 0 2- match_default normal bk_plus_qm REG_EXTENDED REG_NO_POSIX_TEST+ + 0 1\+ !a\+ aa 0 2; now try operator ?- match_default normal REG_EXTENDEDa? b 0 0ab? a 0 1ab? ab 0 2ab? sssabbbbbbsss 3 5ab?c? a 0 1ab?c? abbb 0 2ab?c? accc 0 2ab?c? abcc 0 3?a !\<? !\>? !\n? \n\n 0 1\? ? 0 1\? ?? 0 1\?? ?? 0 1- match_default normal bk_plus_qm REG_EXTENDED REG_NO_POSIX_TEST? ? 0 1\? !a\? aa 0 1a\? b 0 0- match_default normal limited_opsa? a? 0 2a+ a+ 0 2a\? a? 0 2a\+ a+ 0 2; now try operator {}- match_default normal REG_EXTENDEDa{2} a -1 -1a{2} aa 0 2a{2} aaa 0 2a{2,} a -1 -1a{2,} aa 0 2a{2,} aaaaa 0 5a{2,4} a -1 -1a{2,4} aa 0 2a{2,4} aaa 0 3a{2,4} aaaa 0 4a{2,4} aaaaa 0 4; spaces are now allowed inside {}"a{ 2 , 4 }" aaaaa 0 4a{} !"a{ }" !a{2 !a} !\{\} {} 0 2- match_default normal bk_bracesa\{2\} a -1 -1a\{2\} aa 0 2a\{2\} aaa 0 2a\{2,\} a -1 -1a\{2,\} aa 0 2a\{2,\} aaaaa 0 5a\{2,4\} a -1 -1a\{2,4\} aa 0 2a\{2,4\} aaa 0 3a\{2,4\} aaaa 0 4a\{2,4\} aaaaa 0 4"a\{ 2 , 4 \}" aaaaa 0 4{} {} 0 2; now test the alternation operator |- match_default normal REG_EXTENDEDa|b a 0 1a|b b 0 1a(b|c) ab 0 2 1 2a(b|c) ac 0 2 1 2a(b|c) ad -1 -1 -1 -1|c !c| !(|) !(a|) !(|a) !a\| a| 0 2- match_default normal limited_opsa| a| 0 2a\| a| 0 2| | 0 1- match_default normal bk_vbar REG_NO_POSIX_TESTa| a| 0 2a\|b a 0 1a\|b b 0 1; now test the set operator []- match_default normal REG_EXTENDED; try some literals first[abc] a 0 1[abc] b 0 1[abc] c 0 1[abc] d -1 -1[^bcd] a 0 1[^bcd] b -1 -1[^bcd] d -1 -1[^bcd] e 0 1a[b]c abc 0 3a[ab]c abc 0 3a[^ab]c adc 0 3a[]b]c a]c 0 3a[[b]c a[c 0 3a[-b]c a-c 0 3a[^]b]c adc 0 3a[^-b]c adc 0 3a[b-]c a-c 0 3a[b !a[] !; then some ranges[b-e] a -1 -1[b-e] b 0 1[b-e] e 0 1[b-e] f -1 -1[^b-e] a 0 1[^b-e] b -1 -1[^b-e] e -1 -1[^b-e] f 0 1a[1-3]c a2c 0 3a[3-1]c !a[1-3-5]c !a[1- !; and some classesa[[:alpha:]]c abc 0 3a[[:unknown:]]c !a[[: !a[[:alpha !a[[:alpha:] !a[[:alpha,:] !a[[:]:]]b !a[[:-:]]b !a[[:alph:]] !a[[:alphabet:]] ![[:alnum:]]+ -%@a0X_- 3 6[[:alpha:]]+ -%@aX_0- 3 5[[:blank:]]+ "a \tb" 1 4[[:cntrl:]]+ a\n\tb 1 3[[:digit:]]+ a019b 1 4[[:graph:]]+ " a%b " 1 4[[:lower:]]+ AabC 1 3; This test fails with STLPort, disable for now as this is a corner case anyway...;[[:print:]]+ "\na b\n" 1 4[[:punct:]]+ " %-&\t" 1 4[[:space:]]+ "a \n\t\rb" 1 5[[:upper:]]+ aBCd 1 3[[:xdigit:]]+ p0f3Cx 1 5; now test flag settings:- escape_in_lists REG_NO_POSIX_TEST[\n] \n 0 1- REG_NO_POSIX_TEST[\n] \n -1 -1[\n] \\ 0 1[[:class:] : 0 1[[:class:] [ 0 1[[:class:] c 0 1; line anchors- match_default normal REG_EXTENDED^ab ab 0 2^ab xxabxx -1 -1^ab xx\nabzz 3 5ab$ ab 0 2ab$ abxx -1 -1ab$ ab\nzz 0 2- match_default match_not_bol match_not_eol normal REG_EXTENDED REG_NOTBOL REG_NOTEOL^ab ab -1 -1^ab xxabxx -1 -1^ab xx\nabzz 3 5ab$ ab -1 -1ab$ abxx -1 -1ab$ ab\nzz 0 2; back references- match_default normal REG_EXTENDEDa(b)\2c !a(b\1)c !a(b*)c\1d abbcbbd 0 7 1 3a(b*)c\1d abbcbd -1 -1a(b*)c\1d abbcbbbd -1 -1^(.)\1 abc -1 -1a([bc])\1d abcdabbd 4 8 5 6; strictly speaking this is at best ambiguous, at worst wrong, this is what most; re implimentations will match though.a(([bc])\2)*d abbccd 0 6 3 5 3 4a(([bc])\2)*d abbcbd -1 -1a((b)*\2)*d abbbd 0 5 1 4 2 3(ab*)[ab]*\1 ababaaa 0 7 0 1(a)\1bcd aabcd 0 5 0 1(a)\1bc*d aabcd 0 5 0 1(a)\1bc*d aabd 0 4 0 1(a)\1bc*d aabcccd 0 7 0 1(a)\1bc*[ce]d aabcccd 0 7 0 1^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5;; characters by code:- match_default normal REG_EXTENDED REG_STARTEND\0101 A 0 1\00 \0 0 1\0 \0 0 1\0172 z 0 1;; word operators:\w a 0 1\w z 0 1\w A 0 1\w Z 0 1\w _ 0 1\w } -1 -1\w ` -1 -1\w [ -1 -1\w @ -1 -1; non-word:\W a -1 -1\W z -1 -1\W A -1 -1\W Z -1 -1\W _ -1 -1\W } 0 1\W ` 0 1\W [ 0 1\W @ 0 1; word start:\<abcd " abcd" 2 6\<ab cab -1 -1\<ab "\nab" 1 3\<tag ::tag 2 5;word end:abc\> abc 0 3abc\> abcd -1 -1abc\> abc\n 0 3abc\> abc:: 0 3; word boundary:\babcd " abcd" 2 6\bab cab -1 -1\bab "\nab" 1 3\btag ::tag 2 5abc\b abc 0 3abc\b abcd -1 -1abc\b abc\n 0 3abc\b abc:: 0 3; within word:\B ab 1 1a\Bb ab 0 2a\B ab 0 1a\B a -1 -1a\B "a " -1 -1;; buffer operators:\`abc abc 0 3\`abc \nabc -1 -1\`abc " abc" -1 -1abc\' abc 0 3abc\' abc\n -1 -1abc\' "abc " -1 -1;; extra escape sequences:\a \a 0 1\f \f 0 1\n \n 0 1\r \r 0 1\t \t 0 1\v \v 0 1;; now follows various complex expressions designed to try and bust the matcher:a(((b)))c abc 0 3 1 2 1 2 1 2a(b|(c))d abd 0 3 1 2 -1 -1a(b|(c))d acd 0 3 1 2 1 2a(b*|c)d abbd 0 4 1 3; just gotta have one DFA-buster, of coursea[ab]{20} aaaaabaaaabaaaabaaaab 0 21; and an inline expansion in case somebody gets trickya[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] aaaaabaaaabaaaabaaaab 0 21; and in case somebody just slips in an NFA...a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) aaaaabaaaabaaaabaaaabweeknights 0 31 21 24 24 31; one really big one1234567890123456789012345678901234567890123456789012345678901234567890 a1234567890123456789012345678901234567890123456789012345678901234567890b 1 71; fish for problems as brackets go past 8[ab][cd][ef][gh][ij][kl][mn] xacegikmoq 1 8[ab][cd][ef][gh][ij][kl][mn][op] xacegikmoq 1 9[ab][cd][ef][gh][ij][kl][mn][op][qr] xacegikmoqy 1 10[ab][cd][ef][gh][ij][kl][mn][op][q] xacegikmoqy 1 10; and as parenthesis go past 9:(a)(b)(c)(d)(e)(f)(g)(h) zabcdefghi 1 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9(a)(b)(c)(d)(e)(f)(g)(h)(i) zabcdefghij 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10(a)(b)(c)(d)(e)(f)(g)(h)(i)(j) zabcdefghijk 1 11 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k) zabcdefghijkl 1 12 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12(a)d|(b)c abc 1 3 -1 -1 1 2"_+((www)|(ftp)|(mailto)):_*" "_wwwnocolon _mailto:" 12 20 13 19 -1 -1 -1 -1 13 19; subtleties of matchinga(b)?c\1d acd 0 3 -1 -1a(b?c)+d accd 0 4 2 3(wee|week)(knights|night) weeknights 0 10 0 3 3 10.* abc 0 3a(b|(c))d abd 0 3 1 2 -1 -1a(b|(c))d acd 0 3 1 2 1 2a(b*|c|e)d abbd 0 4 1 3a(b*|c|e)d acd 0 3 1 2a(b*|c|e)d ad 0 2 1 1a(b?)c abc 0 3 1 2a(b?)c ac 0 2 1 1a(b+)c abc 0 3 1 2a(b+)c abbbc 0 5 1 4 a(b*)c ac 0 2 1 1 (a|ab)(bc([de]+)f|cde) abcdef 0 6 0 1 1 6 3 5a([bc]?)c abc 0 3 1 2a([bc]?)c ac 0 2 1 1 a([bc]+)c abc 0 3 1 2a([bc]+)c abcc 0 4 1 3a([bc]+)bc abcbc 0 5 1 3a(bb+|b)b abb 0 3 1 2a(bbb+|bb+|b)b abb 0 3 1 2a(bbb+|bb+|b)b abbb 0 4 1 3a(bbb+|bb+|b)bb abbb 0 4 1 2(.*).* abcdef 0 6 0 6(a*)* bc 0 0 0 0; do we get the right subexpression when it is used more than once?a(b|c)*d ad 0 2 -1 -1a(b|c)*d abcd 0 4 2 3a(b|c)+d abd 0 3 1 2a(b|c)+d abcd 0 4 2 3a(b|c?)+d ad 0 2 1 1a(b|c?)+d abcd 0 4 2 3a(b|c){0,0}d ad 0 2 -1 -1a(b|c){0,1}d ad 0 2 -1 -1a(b|c){0,1}d abd 0 3 1 2a(b|c){0,2}d ad 0 2 -1 -1a(b|c){0,2}d abcd 0 4 2 3a(b|c){0,}d ad 0 2 -1 -1a(b|c){0,}d abcd 0 4 2 3a(b|c){1,1}d abd 0 3 1 2a(b|c){1,2}d abd 0 3 1 2a(b|c){1,2}d abcd 0 4 2 3a(b|c){1,}d abd 0 3 1 2a(b|c){1,}d abcd 0 4 2 3a(b|c){2,2}d acbd 0 4 2 3a(b|c){2,2}d abcd 0 4 2 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -