You can use regular Perl as a direct replacement for
grep. Just follow perl's expressive syntax to do the same thing:
Code:
perl -n -e 'print if m|<span class="resultBall vMid ball">\K\d+(?=</span>)|;' t5.html
See "man perlre" and "man perlrun". That's just one example with Perl,
there's more than one way to to it. However, if you are processing HTML or even well-formed XML, then regex is the wrong tool for the job, regardless of language.
You'll survive much better with a proper XML or HTML parser. There are several for Python and Perl or standalone ones like
xmlstarlet:
Code:
xmstarlet sel -N xhtml="http://www.w3.org/1999/xhtml" -t -v '//xhtml:span[@class="resultBall"]' 2>/dev/null t5.html
It might seem a little complex at first, but it uses
XPath like you would with some of the Python and Perl based XML / HTML parsers, and which are similar to what you have used in CSS already.