Skip to main content
2 of 2
fix
J B
  • 10k
  • 27
  • 60

Perl regex, 24 69

^.(.+)(?{$a=$+})((??{"\Q$a"})(?{$a=substr$a,1}))*(?(?{''eq$a})$|(*F))

Obviously not a genuine CS regular expression, but those modern recursive regexes can work wonders and the edited (but fixed) version is not that short at all. I'm starting to wonder if actual Perl code, with the ability to reverse the starting string, wouldn't be shorter than that.

J B
  • 10k
  • 27
  • 60