Perl regex to match exact string
$clean_compare_search = "BangorCaernarfonshire";
$clean_refined_loc = "Caernarfon";
if ($clean_compare_search =~ m/$clean_refined_loc/i)
{
print "Matched";
}
I want to do an exact match of "Caernarfon" and "BangorCaernarfonshire".
Moreover I want regex to match only if "Caernarfonshire" exists in
$clean_refined_loc
As both $clean_compare_search and $clean_refined_loc are dynamic I cannot
do m/^$clean_refined_loc$/i .
Could any please suggest a regex which matches only if "Caernarfonshire"
exists in $clean_refined_loc?
As "Caernarfon" and "Caernarfonshire" are different locations, I want to
match exact location out of "BangorCaernarfonshire"
No comments:
Post a Comment