I have a query string whose possible values could be $str1 and $str2. The requirement is I have to enclose the value
after like/not like clause by %.
Problem is $str1 is working but not $str2
Please help me with a regular expression which will match both $str1 and $str2
my $str1 = "(View like all data) AND (Path not like /usr/bin)"; # work
my $str2 = "(View like all data AND Path not like /usr/bin)";
# not working
while ($str1 =~ /\(\s*[\W\w]+?(like|not like)\s+([^%][\w\W][^%]+?)\s*\
my $new = "%".$2."%";
$str =~ s/$2/$new/;
N.B: 'Path' and 'View' can not be hardcoded in the regex as they might be anything in my $str1 and $atr2,like 'Project',
In both cases the final string should be :
$str1 = "(View like all %data%) AND (Path not like %/usr/bin%)"
$str2 = "(View like all %data% AND Path not like %/usr/bin%)"