如何创建匹配MySQL空间多线字符串坐标的正则表达式。 匹配:
(33 44, 98 33)
(10 10, 20 20), (15 15, 30 15)
(10 10, 20 20), (15 15, 30 15), (10 10, 11 11, 22 22)
答案 0 :(得分:2)
(\((?:\d+\s\d+,\s)*\d+\s\d+\))
/(
\( # opening parenthesis "("
(?: # non-capturing group "("
\d+ # one or more number "(33"
\s # a space "(33 "
\d+ # one or more number "(33 44"
,\s # a comma and a space "(33 44, "
)* # repeat n time "(33 44, "
\d+\s\d+ # plus a last one "(33 44, 98 33"
\) # closing parenthesis "(33 44, 98 33)"
)/x
((?:\((?:\d+\s\d+,\s)*\d+\s\d+\),\s)*\((?:\d+\s\d+,\s)*\d+\s\d+\))
/(
(?: # non-capturing group ""
\((?:\d+\s\d+,\s)*\d+\s\d+\) # cf first regex "(10 10, 20 20)"
,\s # comma and space "(10 10, 20 20), "
)* # repeat n time "(10 10, 20 20), (15 15, 30 15), "
\((?:\d+\s\d+,\s)*\d+\s\d+\) # plus a last one "(10 10, 20 20), (15 15, 30 15), (10 10, 11 11, 22 22)"
)/x