Search code examples
javaregexgeoserver

regex for viewparam on geoserver


Geoserver 2.1-RC1

I am trying to create a valid regular expression that geoserver use to validate viewparams.

Basically I have a sql that end like this

table.field in( '%field%' )

where the %field% geoserver must change for the viewparams that came from a openlayers call.

The value for the %field% must be something like:

'cake'
'cheesecake','pie'
'cake or pie', 'pie','cheesecake'

I've managed to create this expression

^[\']+[\d,\w,\s]+[\']*([\,]*[[\']+[\d,\w,\s]+[\'])*

It works just fine on all the online regex tester I have found, but when I try to save on geoserver I got this error:

Invalid regular expression ^[\']+[\d,\w,\s]+[\']*([\,]*[[\']+[\d,\w,\s]+[\'])*: Unclosed character class near index 50 [\']+[\d,\w,\s]+[\']*([\,]*[[\']+[\d,\w,\s]+[\'])*

There is anyone who could give me a hint about it? I'm not very skilled at regular expressions.


Solution

  • I found it!

    it is here [[\'] this [[ should be [

    But I have no Idea why the online regex testers have accepted it.