in reply to Perl regular expression

Appears that something simple will work. I don't think a URL can have a space in it, so capture all non-space stuff at the beginning (maybe allow for some leading spaces?). Whatever the message is at the end, it will be ignored - doesn't really matter what the URL is (or the number at the end). Note it is important to anchor the regex to the start of the string.
#!/usr/bin/perl -w use strict; my $line = 'https://domain.com/account/confirm_email/JodiImus40/589HC- +CG26G-133578 Once you confirm, you will have full access and all futu +re n= otifications will be sent to this email address.'; #just print the first URL part my ($url) = $line =~ /^\s*(\S+)/; print "$url\n" if $url; #https://domain.com/account/confirm_email/JodiImus40/589HC-CG26G-13357 +8 #edit $line to remove all but the first URL part $line =~ s/^\s*(\S+).*/$1/; print $line; #https://domain.com/account/confirm_email/JodiImus40/589HC-CG26G-13357 +8