I'm trying to create regex patterns to be used in Java for the following two strings:
CIRCLE ( (187.8562 ,-88.562 ) , 0.774 )
and
POLYGON ( (17.766 55.76676,77.97666 -32.866888,54.97799 54.2131,67.666777 24.9771,17.766 55.76676) )
Please note that
one/more white spaces may exist anywhere.Exceptions are not between alphabets.And not between any digits of a number. [UPDATED]
CIRCLE and POLYGON words are fixed but are not case sensitive.[UPDATED]
For the 2nd string the number of point set are not fixed.Here I've given 5 set of points for simplicity.
points are set of decimal/integer numbers [UPDATED]
positive decimal number can have a + sign [UPDATED]
leading zero is not mandatory for a decimal number [UPDATED]
For polygon atleast 3 point set are required.And also first & last point set will be the same (enclosed polygon) [UPDATED]
Any help or suggestion will be appreciated.
I've tried as:
(CIRCLE)(\\s+)(\\()(\\s+)(\\()(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9\\.])(\\s+)(,)(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9\\.])(\\s+)(\\))(\\s+)(,)(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9\\.])(\\s+)(\\))
Could you please provide me the working regex pattern for those two string?