Documentation for regex
^^ assembled from the following types:
^^ anchor matches at the start of a logical line. That is, either at the start of the string, or after a newline character. However, it does not match at the end of the string, even if it ends with a newline character.
$$ anchor matches at the end of a logical line. That is, before a newline character, or at the end of the string when the last character is not a newline character.
To understand the following example, it's important to know that the
q:to/EOS/...EOS heredoc syntax removes leading indention to the same level as the
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.
my =# 'There' is at the start of stringsay so ~~ /^^ There/; # OUTPUT: «True␤»# 'limericks' is not at the start of a linesay so ~~ /^^ limericks/; # OUTPUT: «False␤»# 'as' is at start of the last linesay so ~~ /^^ as/; # OUTPUT: «True␤»# there are blanks between start of line and the "When"say so ~~ /^^ When/; # OUTPUT: «False␤»# 'Japan' is at end of first linesay so ~~ / Japan $$/; # OUTPUT: «True␤»# there's a . between "scan" and the end of linesay so ~~ / scan $$/; # OUTPUT: «False␤»# matched at the last linesay so ~~ / '."' $$/; # OUTPUT: «True␤»