c:\@Work\Perl\monks>perl -wMstrict -le "my @data = ( 'NABCv-ABC : NABCv-ABC', 'BC8200 3*AB25 Products : BC8200 3*AB25 Products', ' BC8200 3*AB25 Products : BC8200 3*AB25 Products ', ' Q : Q ', 'something : else', 'U:U', ' : V', 'W : ', 'X', '', ); ;; DATUM: for my $datum (@data, @ARGV) { my $parsed = my ($ya, $ex) = $datum =~ m{ \A \s* (\S .*?) \s+ : \s+ (\S .*?) \s* \z }xms; ;; if (not $parsed) { print qq{nothing parsed from '$datum'}; next DATUM; } s{ \A \s+ | \s+ \z }{}xmsg for $ya, $ex; print qq{'$ya' and '$ex' are }, $ya eq $ex ? '' : 'NOT ', 'equal'; } " "what : ever" 'NABCv-ABC' and 'NABCv-ABC' are equal 'BC8200 3*AB25 Products' and 'BC8200 3*AB25 Products' are equal 'BC8200 3*AB25 Products' and 'BC8200 3*AB25 Products' are equal 'Q' and 'Q' are equal 'something' and 'else' are NOT equal nothing parsed from 'U:U' nothing parsed from ' : V' nothing parsed from 'W : ' nothing parsed from 'X' nothing parsed from '' 'what' and 'ever' are NOT equal