Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Python

r"
<svg.*?viewBox=\"(-?(?:\d+(?:\.\d+)?|\.\d+)(?:e\d+)?)\s*(-?(?:\d+(?:\.\d+)?|\.\d+)(?:e\d+)?)\s*(-?(?:\d+(?:\.\d+)?|\.\d+)(?:e\d+)?)\s*(-?(?:\d+(?:\.\d+)?|\.\d+)(?:e\d+)?)\".*?>
"
is

Description

for finding and extracting numbers from the viewbox attribute. see also my generalized SVG number regex.

  • v2: added support for scientific notation
Submitted by riedler - 2 months ago (Last modified a month ago)