I have a string "John says hello". How to write if condition which would work like this: if string ends with words "says hello", then ......?
I thought about separating string with regular expressions first like this:
$r =~ /(\w+) (\w+) (.+)/;
my($user,$msg) = ($1,"$2 $3");
if ($msg eq "says hello"){
....
}
But I want to write it without separating it using regex. How to do that?
Aucun commentaire:
Enregistrer un commentaire