where I want to find and print "earth_text". This I can do with a one liner:<div><ul class="test"> <li><a href="/www/?category=Earth">earth_text</a></li></div>
However the file also has cases where there are multiple entries; for example:perl -lne 'BEGIN{undef $/} while (/<div><ul class="test">.*?<li><a hre +f=\"\/www\/\?category=.*?\">(.*?)<\/a><\/li></div>/sg){print $1}' ind +ex.html
Is there a way to find one or multiple instances of <li>...</li>? That is, since they are associated with the same code block, I want perl to return $1="earth_text" and $2="space_text" in the above example and spit out the text like:<div><ul class="test"> <li><a href="/www/?category=Earth">earth_text</a></li> <li><a href="/www/?category=Space">space_text</a></li></div>
Ideally this should work for an arbitrary number of matches including 1.print $1 . "; " . $2
In reply to searching for one or more instances of text between tags by kachunyu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |