I am trying to see if a string1 is in string2 in perl
$Item1="I Like Coffee";
$Item2="2 I Like Coffee";
$Item3="I like Milke";
$Item1=$Item2 but $Item1!=$item3
One way to do it is to strip out the 2 at the beginning of the $item2 and then compare. As follows:
$item=~s/(\d+)//;
Then we can compare.
Rather the better way would be to grep for Item1 in the Item2 and if true do the rest. But grep works only on lists, Is there subtle way to do this? Thanks!
1 Answer