Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(-?[1-8]?\d(?:\.\d{1,18})?|90(?:\.0{1,18})?),\s*?(-?(?:1[0-7]|[1-9])?\d(?:\.\d{1,18})?|180(?:\.0{1,18})?)$
/
gmi

Description

GPS coords from GMpas are as:

  • 47.338388, 0.990228
  • -47.338388, -0.990228

This regex will extract 47.338388 in $1 and 0.990228 in $2 .

Submitted by freMea - 8 years ago