regex - Regular expressions Perl -


regular expression matches 3 consecutive copies of regular expression foo|bar. pattern should match foofoofoo, foobarbar, barbarbar

if($line!~m/((foo)+|(bar)+){0,3}/){print"no match\n";} else {   print "$`";       #print out first part of string     print "<$&>";     #highlight matching part     print "$'";       #print out rest } 

this expression, works, somehow check part string.

for example:

input foo: highlight foo

input foofdafdafbar: highlight foo not bar

i need check if either foo or bar exist, want make sure when both exist, both highlight

your regex doesn't make sense, based off describe want. additionally, secondary examples seem contradict want in first part.

perhaps you're looking is?

if ($line =~ m/((?:foo|bar){3})/) { 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -