Skip to content

Commit 8fe2c15

Browse files
committed
a bit on character ranges
1 parent a6ff140 commit 8fe2c15

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/regexes.pod

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,22 @@ supposed to work, but not supported by Rakudo at the time of writing).
264264
265265
=head2 Enumerated character classes and ranges
266266
267-
TODO
267+
Sometimes the pre-existing wildcards and character classes are just not
268+
enough. Fortunately, defining your own is simple enough. Between C<< <[ ]> >>,
269+
you can put any number of single characters and ranges of characters (expressed
270+
with two dots between the end points) between them, with or without whitespace.
271+
272+
"abacabadabacaba" ~~ / <[ a .. c 1 2 3 ]> /
273+
274+
In between the C<< < > >>, you can also use the same operators for categories
275+
(C<+>, C<|>, C<&>, C<->, C<^>) to combine multiple range definitions and even
276+
mix in some of the unicode categories above. Another thing you are allowed to
277+
write between the C< [ ] > is the backslashed forms for character classes.
278+
279+
/ <[\d] - [13579]> /
280+
# not quite the same as
281+
/ <[02468]>
282+
# because the first one also contains "weird" unicodey digits
268283
269284
=head1 Quantifier
270285

0 commit comments

Comments
 (0)