regex - Groovy: Escaping an arbitrary (unknown) regular expression -


I want to split a string through String.split (k) where k is an arbitrary string (read from the input ). The problem is that Kashmir can be a string and thus regular expression operators may be included, such as: "* [" .

In such cases, the partitioned method leaves an exception because regular expression is not formed properly.

What I see is a way of avoiding any Kashmir, as a result that the string can be passed safely on the partition ().

Any thoughts?

You can use * to avoid the regex pattern.

*: 'Escapet' rather seems childish.


Comments

Popular posts from this blog

asp.net - Change the driver in the connection string to a data source in VB.Net -

Getting started consuming web services in a Ruby on Rails 3 application -

unix - Listing all shared memory segments used by a process on AIX5.3+ -