If the line you want always begins <li>average_, then match on that (according to your taste, including or excluding the <li>s from your capture) rather than trying to count <li>s.
If not, you'll have to use a more complex solution... for which you may wish to read in the regex docs about "positive look ahead" and variations.
In reply to Re: Query about regular expression
by ww
in thread [Solved]: Query about regular expression
by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |