Also how do I match entire word when there are special characters?
In many cases NOTSPACE or some other exclusionary pattern that matches any character up to a certain boundary in more useful than an inclusionary pattern that specifies which characters to match.
NOTSPACE will match a sequence of non-whitespace characters while WORD matches sequences of characters that occur on words (which, perhaps oddly, doesn't include hyphens). If this doesn't answer your question I don't understand what you're asking.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.