I am trying to fetch the content between the tags. So i made regex for the same.
final String REGEX_BOLD_END = ".*[<][/][B|b][>].*";
String input = "<B>Contetnt here</B>";
Pattern pattern_start = Pattern.compile(".*[<][B|b][>].*");
Matcher matcher_start = pattern_start.matcher(input);
Pattern pattern_end = Pattern.compile(REGEX_BOLD_END);
Matcher matcher_end = pattern_end.matcher(input);
System.out.println("Tag open");
if (matcher_start.matches()) {
System.out.println("At:" + matcher_start.start() + "\tTo:" + matcher_start.end());
System.out.println(matcher_start.group(0));
} else {
System.out.println("Not matched");
}
System.out.println("Tag Close");
if (matcher_end.matches()) {
System.out.print("At:" + matcher_end.start() + "\tTo:" + matcher_end.end());
} else {
System.out.println("Not matched");
}
My aim is to get the Content here. So i was thinking to get the start and end index and then fetch the substring out of the original input. But i am getting something what i was not expecting.
output:
Tag open
At:0 To:20
<B>Contetnt here</B>
Tag Close
At:0 To:20
Please point out where i am making mistake.