#!/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 future 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-133578 #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-133578