I am trying to identify Strings (Which means text inside double quotes) in my JTextPane using the following code
Pattern string= Pattern.compile("\"/\"/.*");
Matcher matcher = string.matcher(content);
while (matcher.find()) {
document.setCharacterAttributes(matcher.start(), matcher.end() - matcher.start(), textPane.getStyle("red"), true);
}
But the above code is not identifying Strings correctly. I think the pattern I gave is wrong. Please help me by correcting the pattern.
Thanks all! I really appreciate your help! Since all of your answers are correct, I am in a difficulty of selecting the best answer, so I gave each of you an up vote. Hope you don’t mind it 🙂
Thanks again all! I really really appreciate it 🙂
The right expression is this: