if ( $word =~ /^([a-zA-Z]+)/ ) {
$word = $1;
}
the
^ matches the start of the string
the
() assigns whatever it matches between them to
$1
update
the above matches any of
[a-zA-Z] at the start of the string
If you want to match
any character before the first
: then do
if ( $word =~ /^([^:]+)/ ) {
$word = $1;
}
the
[^:] means match anything
except a
: