Regular Expressions 101

Community Patterns

Community Library Entry

-1

Regular Expression
PCRE (PHP <7.3)

/
^.*250 g<\/td><td><span[^>]*>([0-9]+)\.([0-9]+[0-9]+[0-9]+)\,([0-9]+[0-9]+)<\/span>.*$
/

Description

Grep the daily purchase price for 250 g gold from http://www.scheideanstalt.de/aktuelle-ankaufskurse/ankaufskurse-barren/:

gold=$(wget -q -O- http://www.scheideanstalt.de/aktuelle-ankaufskurse/ankaufskurse-barren/ | grep "250 g" | sed -r 's/^.250 g</td><td><span[^>]>([0-9]+).([0-9]+[0-9]+[0-9]+),([0-9]+[0-9]+)</span>.*$/\1\2.\3/')

echo $gold

Submitted by MH - 9 years ago