Alex Alex - 1 year ago 92
Perl Question

Perl regex first word

I am very new to regex in perl and I have the following line:

MD5ajdhe728ndsdhsds83ndsds /some/path/

and I just want to get the MD5 value (the number/letter combination after "MD5"). How do I do that? I have kind of troubles fetching the first word.

Thank you in advance.

Answer Source
use strict;
use warnings;
my $line = q{MD5ajdhe728ndsdhsds83ndsds /some/path/};
$line =~ /^MD5([a-zA-Z0-9]+)/;
print $1; 


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download