my $search = "foo"; my $len=length($search); #finding the length of the pattern my @array = ("s1 bar", "foo", "s3 foo"); print grep {/.*\b(.{$len})/;$_=$& if $1 eq $search;} @array; #checking whether the end characters of the string in the array is same as the pattern given
In reply to Re: grep regex exact match last n positions
by nvivek
in thread grep regex exact match last n positions
by coldy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |