File: rx_metachars

package info (click to toggle)
nqp 2022.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,436 kB
  • sloc: java: 28,030; perl: 3,394; ansic: 451; makefile: 200; javascript: 68; sh: 1
file content (250 lines) | stat: -rw-r--r-- 10,837 bytes parent folder | download | duplicates (3)
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
##   Metacharacter tests
.			a		y	dot (.)
.			\n		y	dot (.)
.			''		n	dot (.)
a\s+f			abcdef		n	whitespace (\s)
ab\s+cdef		ab  cdef	y	whitespace (\s)
a\S+f			abcdef		y	not whitespace (\S)
a\S+f			ab cdef		n	not whitespace (\S)
^ abc			abcdef		y	start and end of string (^)
^ abc			abc\ndef	y	start and end of string (^)
^ abc			def\nabc	n	start and end of string (^)
def \n ^ abc		def\nabc	n	start and end of string (^)
def $			abcdef		y	start and end of string ($)
def $			abc\ndef	y	start and end of string ($)
def $			def\nabc	n	start and end of string ($)
def $ \n abc		def\nabc	n	start and end of string (^)
abc \n $		abc\n		y	end of string ($)
abc $			abc\n		n	end of string ($)
<<def			abc-def		y	left word boundary, beginning of word
<<bc			abc-def		n	left word boundary, mid-word
c<<			abc-def		n	left word boundary, end of word
<<abc			abc-def		y	left word boundary, BOS
def<<			abc-def		n	left word boundary, EOS
<<			-------		n	left word boundary, no word chars
>>def			abc-def		n	right word boundary, beginning of word
>>bc			abc-def		n	right word boundary, mid-word
c>>			abc-def		y	right word boundary, end of word
>>abc			abc-def		n	right word boundary, BOS
def>>			abc-def		y	right word boundary, EOS
>>			-------		n	right word boundary, no word chars

abc <( def		abcdefghi	<def @ 3>	from <( marker
abc <( def		abcde		n		from <( marker in failed match
abc )> def		abcdefghi	<abc @ 0>	to )> marker
abc <( \d+ )> def	abc123def	<123 @ 3>	from <( and to >)
abc <( \d+ def		abc456def	<456def @ 3>	from <( only
abc \d+ )> def		abc789def	<abc789 @ 0>	to )> only
abc <( def || .....	abc123def	<abc12 @ 0>	backtracked from <(
abc <( \d+ <( def	abc123def	<def @ 6>	multiple <('s

c \n d			abc\ndef	y	logical newline (\n)
c \n d			abc\rdef	y	logical newline matches \r
c \n+ d			abc\n\ndef	y	logical newline quantified
a\n+f			abcdef		n	logical newline (\n)
c \n d			abc\n\rdef	n	logical newline doesn't match \n\r
c \n d			abc\r\ndef	y	logical newline matches \r\n
b \n c			abc\ndef	n	logical newline (\n)
\N			a		y	not logical newline (\N)
a \N c			abc		y	not logical newline (\N)
\N			''		n	not logical newline (\N)
c \N d			abc\ndef	n	not logical newline (\N)
c \N d			abc\rdef	n	not logical newline (\N)
c \N+ d			abc\n\ndef	n	not logical newline (\N)
a\N+f			abcdef		y	not logical newline (\N)
c \N d			abc\n\rdef	n	not logical newline (\N)
c \N d			abc\r\ndef	n	not logical newline (\N)
b \N \n			abc\ndef	y	not logical newline (\N)
\Aabc			Aabc		[Unsupported]	retired metachars (\A)
\Aabc			abc\ndef	[Unsupported]	retired metachars (\A)
abc\Z			abcZ		[Unsupported]	retired metachars (\Z)
abc\Z			abc\ndef	[Unsupported]	retired metachars (\Z)
abc\z			abcz		[Unsupported]	retired metachars (\z)
def\z			abc\ndef	[Unsupported]	retired metachars (\z)
abc # def		abc#def		y	comments (#)
abc # xyz		abc#def		y	comments (#)
abc # def \n \$		abc#def		y	comments (#)
abc '#' def		abc#def		y	comments (#)
abc '#' xyz		abc#def		n	comments (#)
^ abc '#' def $		abc#def		y	comments (#)
^^ abc \n ^^ def	abc\ndef	y	line beginnings and endings (^^)
^^ abc \n ^^ def \n ^^	abc\ndef\n	n	line beginnings and endings (^^)
^^ \n			\n		y	line beginnings and endings (^^)
\n ^^			\n		n	line beginnings and endings (^^)
abc $$ \n def $$	abc\ndef	y	line beginnings and endings ($$)
abc $$ \n def $$ \n $$	abc\ndef\n	n	line beginnings and endings ($$)
$$ \n			\n		y	line beginnings and endings ($$)
\n $$			\n		n	line beginnings and endings ($$)
<[a..d]> | <[b..e]>	c		y	alternation (|)
<[a..d]> | <[d..e]>	c		y	alternation (|)
<[a..b]> | <[b..e]>	c		y	alternation (|)
<[a..b]> | <[d..e]>	c		n	alternation (|)
<[a..d]>+ | <[b..e]>+	bcd		y	alternation (|)
^ [ <[a..d]>+ | <[b..e]>+ ] $	bcd		y	alternation (|)
^ [ <[a..c]>+ | <[b..e]>+ ] $	bcd		y	alternation (|)
^ [ <[a..d]>+ | <[c..e]>+ ] $	bcd		y	alternation (|)
b|			bcd		[Null regex]	alternation (|) - null right arg illegal
|b			bcd		y	alternation (|) - null left arg ignored
|			bcd		[Null regex]	alternation (|) - null both args illegal
\|			|		y	alternation (|) - literal must be escaped
|			|		[Null regex]	alternation (|) - literal must be escaped
<[a..d]> && <[b..e]>	c		y	conjunction (&&)
<[a..d]> && <[d..e]>	c		n	conjunction (&&)
<[a..b]> && <[b..e]>	c		n	conjunction (&&)
<[a..b]> && <[d..e]>	c		n	conjunction (&&)
<[a..d]>+ && <[b..e]>+	bcd		y	conjunction (&&)
^ [ <[a..d]>+ && <[b..e]>+ ] $	bcd		y	conjunction (&&)
<[a..c]>+ && <[b..e]>+	bcd		y	conjunction (&&)
<[a..d]>+ && <[c..e]>+	bcd		y	conjunction (&&)
b&			bcd		[Null regex]	conjunction (&) - null right arg illegal
&			bcd		[Null regex]	conjunction (&) - null both args illegal
\&			&		y	conjunction (&) - literal must be escaped
&			&		[Null regex]	conjunction (&) - literal must be escaped
a&|b			a&|b		[Null regex]	alternation and conjunction (&|) - parse error
&			&		[Null regex]	conjunction (&) - literal must be escaped
a|&b			a|&b		y	alternation and conjunction (|&) - leading & inside | is okay
|d|b			abc		y	leading alternation ignored
 |d|b			abc		y	leading alternation ignored
|d |b			abc		y	leading alternation ignored
 | d | b		abc		y	leading alternation ignored
\pabc			pabc		[Unrecognized]	retired metachars (\p)
\p{InConsonant}		a		[Unrecognized]	retired metachars (\p)
\Pabc			Pabc		[Unrecognized]	retired metachars (\P)
\P{InConsonant}		a		[Unrecognized]	retired metachars (\P)
\Labc\E			LabcE		[Unrecognized]	retired metachars (\L...\E)
\LABC\E			abc		[Unrecognized]	retired metachars (\L...\E)
\Uabc\E			UabcE		[Unrecognized]	retired metachars (\U...\E)
\Uabc\E			ABC		[Unrecognized]	retired metachars (\U...\E)
\Qabc\E			QabcE		[Unsupported]	retired metachars (\Q...\E)
\Qabc d?\E		abc d		[Unsupported]	retired metachars (\Q...\E)
\Gabc			Gabc		[Unrecognized]	retired metachars (\G)
\1abc			1abc		[Unrecognized]	retired metachars (\1)
^ \s+ $			\x0009\x0020\x00a0\x000a\x000b\x000c\x000d\x0085	y	0-255 whitespace (\s)
^ \h+ $			\x0009\x0020\x00a0	y	0-255 horizontal whitespace (\h)
^ \V+ $			\x0009\x0020\x00a0	y	0-255 horizontal whitespace (\V)
^ \v+ $			\x000a\x000b\x000c\x000d\x0085	y	0-255 vertical whitespace (\v)
^ \h+ $			\x000a\x000b\x000c\x000d\x0085	n	0-255 horizontal whitespace (\h)
^ \v+ $			\x0009\x0020\x00a0	n	0-255 vertical whitespace (\v)
^ \s+ $			\x1680\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2008\x2009\x200a\x202f\x205f\x3000	y	unicode whitespace (\s)
^ \h+ $			\x1680\x180e\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2008\x2009\x200a\x202f\x205f\x3000	y	unicode whitespace (\h)
^ \V+ $			\x1680\x180e\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2008\x2009\x200a\x202f\x205f\x3000	y	unicode whitespace (\V)
^ \v+ $			\x1680\x180e\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2008\x2009\x200a\x202f\x205f\x3000	n	unicode whitespace (\v)
c \t d			abc\tdef	y	horizontal tab (\t)
c \t+ d			abc\t\tdef	y	horizontal tab (\t)
a \t+ f			abcdef		n	horizontal tab (\t)
b \t c			abc\tdef	n	horizontal tab (\t)
\T			a		y	not horizontal tab (\T)
a \T c			abc		y	not horizontal tab (\T)
\T			''		n	not horizontal tab (\T)
c \T d			abc\tdef	n	not horizontal tab (\T)
c \T+ d			abc\t\tdef	n	not horizontal tab (\T)
a \T+ f			abcdef		y	not horizontal tab (\T)
c \r d			abc\rdef	y	return (\r)
c \r+ d			abc\r\rdef	y	return (\r)
a \r+ f			abcdef		n	return (\r)
b \r c			abc\rdef	n	return (\r)
\R			a		y	not return (\R)
a \R c			abc		y	not return (\R)
\R			''		n	not return (\R)
c \R d			abc\rdef	n	not return (\R)
c \R+ d			abc\r\rdef	n	not return (\R)
a \R+ f			abcdef		y	not return (\R)
c \f d			abc\fdef	y	formfeed (\f)
c \f+ d			abc\f\fdef	y	formfeed (\f)
a \f+ f			abcdef		n	formfeed (\f)
b \f c			abc\fdef	n	formfeed (\f)
\F			a		y	not formfeed (\F)
a \F c			abc		y	not formfeed (\F)
\F			''		n	not formfeed (\F)
c \F d			abc\fdef	n	not formfeed (\F)
c \F+ d			abc\f\fdef	n	not formfeed (\F)
a \F+ f			abcdef		y	not formfeed (\F)
c \e d			abc\edef	y	escape (\e)
c \e+ d			abc\e\edef	y	escape (\e)
a \e+ f			abcdef		n	escape (\e)
b \e c			abc\edef	n	escape (\e)
\E			a		y	not escape (\E)
a \E c			abc		y	not escape (\E)
\E			''		n	not escape (\E)
c \E d			abc\edef	n	not escape (\E)
c \E+ d			abc\e\edef	n	not escape (\E)
a \E+ f			abcdef		y	not escape (\E)
c \x0021 d		abc!def	y	hex (\x)
c \x0021+ d		abc!!def	y	hex (\x)
a \x0021+ f		abcdef		n	hex (\x)
b \x0021 c		abc!def		n	hex (\x)
c \x[0021] d		abc!def		y	hex (\x[])
c \x[0021]+ d		abc!!def	y	hex (\x[])
c \x[21,21] d		abc!!def	y	hex (\x[])
c \x[21, 21] d		abc!!def	y	hex (\x[])
c \x[ 21 , 21 ] d	abc!!def	y	hex (\x[])
a \x[0021]+ f		abcdef		n	hex (\x[])
b \x[0021] c		abc!def		n	hex (\x[])
\X0021			a		y	not hex (\X)
a \X0021 c		abc		y	not hex (\X)
\X0021			''		n	not hex (\X)
c \X0021 d		abc!def		n	not hex (\X)
c \X0021+ d		abc!!def	n	not hex (\X)
a \X0021+ f		abcdef		y	not hex (\X)
\X[0021]		a		y	not hex (\X[])
a \X[0021] c		abc		y	not hex (\X[])
\X[0021]		''		n	not hex (\X[])
c \X[0021] d		abc!def		n	not hex (\X[])
c \X[0021]+ d		abc!!def	n	not hex (\X[])
a \X[0021]+ f		abcdef		y	not hex (\X[])
c \c33 d		abc!def	y	hex (\c)
c \c33+ d		abc!!def	y	hex (\c)
a \c33+ f		abcdef		n	hex (\c)
b \c33 c		abc!def		n	hex (\c)
c \c[33] d		abc!def		y	hex (\c[])
c \c[33]+ d		abc!!def	y	hex (\c[])
c \c[33,33] d		abc!!def	y	hex (\c[])
c \c[ 33, 33] d		abc!!def	y	hex (\c[])
c \c[ 33 , 33 ] d	abc!!def	y	hex (\c[])
a \c[33]+ f		abcdef		n	hex (\c[])
b \c[33] c		abc!def		n	hex (\c[])
\C33			a		y	not hex (\C)
a \C33 c		abc		y	not hex (\C)
\C33			''		n	not hex (\C)
c \C33 d		abc!def		n	not hex (\C)
c \C33+ d		abc!!def	n	not hex (\C)
a \C33+ f		abcdef		y	not hex (\C)
\C[33]			a		y	not hex (\C[])
a \C[33] c		abc		y	not hex (\C[])
\C[33]			''		n	not hex (\C[])
c \C[33] d		abc!def		n	not hex (\C[])
c \C[33]+ d		abc!!def	n	not hex (\C[])
a \C[33]+ f		abcdef		y	not hex (\C[])
c \o041 d		abc!def		y	octal (\o)
c \o41+ d		abc!!def	y	octal (\o)
a \o41+ f		abcdef		n	octal (\o)
b \o41 c		abc!def		n	octal (\o)
c \o[41] d		abc!def		y	octal (\o[])
c \o[41]+ d		abc!!def	y	octal (\o[])
c \o[41,41] d		abc!!def	y	octal (\o[])
a \o[41]+ f		abcdef		n	octal (\o[])
b \o[41] c		abc!def		n	octal (\o[])
\O41			a		y	not octal (\O)
a \O41 c		abc		y	not octal (\O)
\O41			''		n	not octal (\O)
c \O41 d		abc!def		n	not octal (\O)
c \O41+ d		abc!!def	n	not octal (\O)
a \O41+ f		abcdef		y	not octal (\O)
\O[41]			a		y	not octal (\O[])
a \O[41] c		abc		y	not octal (\O[])
\O[41]			''		n	not octal (\O[])
c \O[41] d		abc!def		n	not octal (\O[])
c \O[41]+ d		abc!!def	n	not octal (\O[])
a \O[41]+ f		abcdef		y	not octal (\O[])
a\w+f			a=[ *f		n	word character
a\w+f			abcdef		y	word character
a\W+f			a&%- f		y	not word character
a\W+f			abcdef		n	not word character
a\d+f			abcdef		n	digit
ab\d+cdef		ab42cdef	y	digit
a\D+f			abcdef		y	not digit
a\D+f			ab0cdef		n	not digit
a[b<!>]?cd		abcd		n	failing assertion reached
a[b<!>]?cd		acd		y	failing assertion not reached

## vim: noexpandtab tabstop=4 shiftwidth=4