Regular Expressions 101

Community Patterns

Comma Separated Longitude Latitude Pair Validator

0

Regular Expression
PCRE (PHP <7.3)

/
^((-?(\d{1,3})(\.\d+)?,\s*){2}){3,}$
/

Description

Validates whether a list of long/lat coordinate pairs are valid. Requires at least 3 pairs, and requires comma at the end of the final pair. Each single coordinate is separated by a comma, and all coordinate pairs must be separated by a comma

Submitted by anonymous - 5 years ago