我试图提出两个正则表达式,一个用于纬度值,-85.05112878< lat< 85.05112878,一个用于经度值,-180.0<长< 180.0
非常感谢帮助
答案 0 :(得分:1)
不是很漂亮,你可以试试这个纬度
-85.05112878< lat < 85.05112878 强>
^(?:-?85\.0(?:000000\d*|0{1,5}(?:[1-9]\d*)?|[1-4]\d*|5(?:0\d*)?|5(?:1(?:0\d*)?)?|511(?:[0-1]\d*)?|5112(?:[0-7]\d*)?|51128(?:[0-6]\d*)?|511287[0-8]?)?0*|(?:-[1-9]|-?[1-7]\d|-?8[0-4]|\d)\.\d+)$
扩展
^
(?:
-? 85
\.0
(?:
000000 \d*
| 0{1,5} (?: [1-9] \d* )?
| [1-4] \d*
| 5 (?: 0 \d* )?
| 5 (?: 1 (?: 0 \d* )? )?
| 511 (?: [0-1] \d* )?
| 5112 (?: [0-7] \d* )?
| 51128 (?: [0-6] \d* )?
| 511287 [0-8]?
)?
0*
|
(?:
- [1-9]
| -? [1-7] \d
| -? 8 [0-4]
| \d
)
\. \d+
)
$
这是经度
-180.0< long < 180.0 强>
^(?:-?180\.0+|(?:-[1-9]|-?[1-9]\d|-?1[0-7]\d|\d)\.\d+)$
扩展
^
(?:
-? 180 \. 0+
|
(?:
- [1-9]
| -? [1-9] \d
| -? 1 [0-7] \d
| \d
)
\. \d+
)
$
修改
除了与
之类的部分(有效)形式匹配外,它与上述相同54
54.
54.1
等...
lat
^(?:-?85(?:\.(?:0(?:000000\d*|0{1,5}(?:[1-9]\d*)?|[1-4]\d*|5(?:0\d*)?|5(?:1(?:0\d*)?)?|511(?:[0-1]\d*)?|5112(?:[0-7]\d*)?|51128(?:[0-6]\d*)?|511287[0-8]?)?)?0*)?|(?:-[1-9]|-?[1-7]\d|-?8[0-4]|\d)(?:\.\d*)?)$
扩展
^
(?:
-? 85
(?:
\.
(?:
0
(?:
000000 \d*
| 0{1,5} (?: [1-9] \d* )?
| [1-4] \d*
| 5 (?: 0 \d* )?
| 5 (?: 1 (?: 0 \d* )? )?
| 511 (?: [0-1] \d* )?
| 5112 (?: [0-7] \d* )?
| 51128 (?: [0-6] \d* )?
| 511287 [0-8]?
)?
)?
0*
)?
|
(?:
- [1-9]
| -? [1-7] \d
| -? 8 [0-4]
| \d
)
(?: \. \d* )?
)
$
长
^(?:-?180(?:\.0*)?|(?:-[1-9]|-?[1-9]\d|-?1[0-7]\d|\d)(?:\.\d*)?)$
扩展
^
(?:
-? 180
(?: \. 0* )?
|
(?:
- [1-9]
| -? [1-9] \d
| -? 1 [0-7] \d
| \d
)
(?: \. \d* )?
)
$