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

objective c - iPhone and it's wireless area -

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

.net - Self Tracking Entities (STE)'s and partial updates with EF4 and mVC2 -