in reply to Regex to detect and remove a linebreak in an URL

How about you read in the mail body, throw out all newlines that are preceded or followed by URI-like punctuation (like /:?&) and then throw URI::Find at it?

Something like this:

use warnings; use strict; use URI::Find; my $data = join '', <DATA>; $data =~ s/(?<=[.:\/?&])\n//g; $data =~ s/\n(?=[.:\/?&])//g; my $finder = URI::Find->new( sub { print "Found: $_[0]\n"; }); $finder->find(\$data); __DATA__ There's a URL http://here.com and a URL http:// there.com. What else? A really long one http://abc .def.com?foo=bar&foo=bar&foo=bar&foo=bar&foo=bar&foo=bar& bar=foo. And this is a regular line break.