I made a mistake in my previous post, as I used a consuming pattern (.+), while it should all have been inside the assertion. Here's the (hopefully) correct code:
Code:
alias lcs2 {
if $regex($+($1,$cr,$2),/(?=(.+).*\r.*\1)/g) {
var %i = $ifmatch, %a = 0
while %i {
if $len($regml(%i)) > %a { var %a = $ifmatch, %b = %i }
dec %i
}
return $regml(%b)
}
}