Stack Overflow Asked by sankrish on February 15, 2021
I have the following regex pattern:
^POLYGONs*(((-?d+(.d+)?)s*(-?d+(.d+)?)))$
I am trying to match the string pattern POLYGON ((77.40970726940513 12.978147980713118,77.37585259873805 13.273612877088299,77.80253462545315 13.185991361443607,77.83326404994843 12.874112460078642,77.60553384375903 12.753157552741165,77.47003961302485 12.860758717988348,77.40044069330365 12.989005488377385,77.40970726940513 12.978147980713118)).
But the regex pattern which I have used above only satisfies the string with values POLYGON ((130.55809472656256 111.333)) .
Need a help on regex expression to match the string like above with multiple lat long values with comma separated groups.
You can optionally repeat the second part of the pattern and match either a comma or a whitespace char to match the whole string.
^POLYGONs*((-?d+(?:.d+)?(?:[,s]-?d+(?:.d+)?)*))$
If they should come in pairs separated by a whitespace char and after lat long a comma, you can optionally repeat the pairs:
^POLYGONs*((-?d+(?:.d+)?s-?d+(?:.d+)?(?:,-?d+(?:.d+)?(?:s-?d+.d+)?)*))$
Correct answer by The fourth bird on February 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP