Search code examples
javaregexhbase

Regular Expressions in java trying to match a string in specific format (format consists of | sysbol)


Regular Expressions in java

String s1="Anil-anilorg|anotherorg";
String s2="Anil-anilorg|";

I want to find weather s2 is present or sub-string of s1 by using regular expressions, but while I am doing that it is considering this symbol "|" as logical OR I am using hbaseStringRegexComparator to compare


Solution

  • You need to escape the | as \|, and within a String it becomes "\\|".