This is what I am trying to do...
Enter Pattern
//*//_//*
Enter Text
hello *_* how are you?
No match found
I know to avoid treating above characters as Metacharacters I need to use these escape sequences. I don't know how to do with _ (underscore sigh)
I even tried
//* _ //*
Still it didn't work.
code
Scanner sc = new Scanner(System.in);
System.out.println("Enter pattern");
Pattern pattern = Pattern.compile(sc.nextLine());
System.out.println("Enter Text");
Matcher matcher = pattern.matcher(sc.nextLine());
boolean found = false;
while(matcher.find())
{
System.out.println("I found the text" + matcher.group() + "Starting index" + matcher.start() + "Ending at index" + matcher.end());
found = true;
}
if(!found)
{
System.out.println("No match found");
}