Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed some code indent problems
  • Loading branch information
Jan-Olof Hendig committed Sep 9, 2016
1 parent 8a94bc5 commit e98f1ae
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions doc/Language/regexes.pod6
Expand Up @@ -340,34 +340,34 @@ To quantify an atom an arbitrary number of times, you can write e.g.
C<a ** 2..5> to match the character C<a> at least twice and at most 5 times.
=begin code
say so 'a' ~~ /a ** 2..5/; # False
say so 'aaa' ~~ /a ** 2..5/; # True
say so 'a' ~~ /a ** 2..5/; # False
say so 'aaa' ~~ /a ** 2..5/; # True
=end code
If the minimal and maximal number of matches are the same, a single integer
is possible: C<a ** 5> matches C<a> exactly five times.
=begin code
say so 'aaaaa' ~~ /a ** 5/; # True
say so 'aaaaa' ~~ /a ** 5/; # True
=end code
It is also possible to use non inclusive ranges using a caret:
=begin code
say so 'a' ~~ /a ** 1^..^6/; # False
say so 'aaaa' ~~ /a ** 1^..^6/; # True
say so 'a' ~~ /a ** 1^..^6/; # False
say so 'aaaa' ~~ /a ** 1^..^6/; # True
=end code
This includes the numeric ranges starting from 0:
=begin code
say so 'aaa' ~~ /a ** ^6/; # True
say so 'aaa' ~~ /a ** ^6/; # True
=end code
or a Whatever operator for an infinite range with a non inclusive minimum:
=begin code
say so 'aaaa' ~~ /a ** 1^..*/; # True
say so 'aaaa' ~~ /a ** 1^..*/; # True
=end code
=head2 X<Modified quantifier: %|regex,%;regex,%%>
Expand All @@ -383,14 +383,14 @@ To match those as well, you may use C<%%> instead of C<%>.
By default, quantifiers request a greedy match:
=begin code
'abababa' ~~ /a .* a/ && say ~$/; # abababa
'abababa' ~~ /a .* a/ && say ~$/; # abababa
=end code
You can attach a C<?> modifier to the quantifier to enable frugal
matching:
=begin code
'abababa' ~~ /a .*? a/ && say ~$/; # aba
'abababa' ~~ /a .*? a/ && say ~$/; # aba
=end code
You can also explicitly request greedy matching with the C<!> modifier.
Expand All @@ -401,8 +401,8 @@ You can prevent backtracking in regexes by attaching a C<:> modifier
to the quantifier:
=begin code
say so 'abababa' ~~ /a .* aba/ # True
say so 'abababa' ~~ /a .*: aba/ # False
say so 'abababa' ~~ /a .* aba/ # True
say so 'abababa' ~~ /a .*: aba/ # False
=end code
=head1 X<Alternation|regex,||>
Expand Down Expand Up @@ -497,23 +497,23 @@ level as the C<EOS> marker, so that the first, second and last lines have no
leading space and the third and fourth lines have two leading spaces each).
=begin code
my $str = q:to/EOS/;
There was a young man of Japan
Whose limericks never would scan.
When asked why this was,
He replied "It's because
I always try to fit as many syllables into the last line as ever I possibly can."
EOS
say so $str ~~ /^^ There/; # True (start of string)
say so $str ~~ /^^ limericks/; # False (not at the start of a line)
say so $str ~~ /^^ I/; # True (start of the last line)
say so $str ~~ /^^ When/; # False (there are blanks between
my $str = q:to/EOS/;
There was a young man of Japan
Whose limericks never would scan.
When asked why this was,
He replied "It's because
I always try to fit as many syllables into the last line as ever I possibly can."
EOS
say so $str ~~ /^^ There/; # True (start of string)
say so $str ~~ /^^ limericks/; # False (not at the start of a line)
say so $str ~~ /^^ I/; # True (start of the last line)
say so $str ~~ /^^ When/; # False (there are blanks between
# start of line and the "When")
say so $str ~~ / Japan $$/; # True (end of first line)
say so $str ~~ / scan $$/; # False (there is a . between "scan"
say so $str ~~ / Japan $$/; # True (end of first line)
say so $str ~~ / scan $$/; # False (there is a . between "scan"
# and the end of line)
say so $str ~~ / '."' $$/; # True (at the last line)
say so $str ~~ / '."' $$/; # True (at the last line)
=end code
=head2 X<<<<C<<< << >>> and C<<< >> >>>, left and right word boundary|regex,<<;regex,>>;regex,«;regex,»>>>>
Expand Down

0 comments on commit e98f1ae

Please sign in to comment.