how can i escape a group of special characters in java in one method?

前端 未结 4 1660
清酒与你
清酒与你 2021-01-11 19:56

i use lucene search but lucene has a bunch of special characters to escape like:

- && || ! ( ) { } [ ] ^ \" ~ * ? : \\

i am havin

4条回答
  •  伪装坚强ぢ
    2021-01-11 20:33

    There is a Apache Commons Library for that: http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html

提交回复
热议问题