- or download this
/(^.*\z)(?(?{ $+ eq reverse $+ })|(?!))/s
- or download this
/
( # capture group
...
/xs # x for readability, s to make . matc
+h \n
# Note: can match empty string
- or download this
rule palindrome {
$foo := (\w+) ::: { fail if $foo ne reverse $foo }
}
# Note: doesn't match empty string
- or download this
/(.+)(??{ reverse $+ })/s
- or download this
/
(.+) # match one or more characters
...
/xs
# Note: doesn't match empty string or single character string
- or download this
rule palindrome {
$foo := (\w+) <{ quotemeta reverse $foo }>
}