Whole word matching with unexpected insertion in data

岁酱吖の 提交于 2019-12-06 05:18:54

Not sure if that is what you need but how about

@b = split('',$pattern);

for my $i(@b){
    $i=$i.".*";
    print "$i \n";
}
$pattern = join('',@b);

That should match any string that had the pattern before it got random insertions as long as the characters of the pattern are still there and in the correct order. It does find evaluated in the string esouhgvw8vwrg355#*asrgl/\u[\w]atet(45)<data>efdvd what is about as noisy as it gets. But of course, if it is impossible to distinguish between insertion and original string, you will get "false" positives. For example if the string used to be evaluted and it becomes something like evalu<hereisyourmissinga>ted you will get a positive. Of course, if you knew that insertions would always be in tags while text is not, users answer is much safer.

As long as you single quote your input string, characters like [\w] (45) and whatnot should not hurt either. I cannot see why they would be interpolated at any point.

Of course, you could use regexp to do the job:

foreach my  $s ($string,$string2){
   my $cs= $s;
   ### canonize
   $cs =~ s!<[^>]*>!!gs;
   ### match
   if ($cs =~ m!$pattern!i){
      print "Found $pattern in $s!\n";
   }        
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!