In my app, i get a list of strings as a response to the http request. In those strings, some strings may contain a html tag at the beginning. The format of the string is like this <span class="qtO">String
. I want to replace the <span>
part. But, the qtO
part of the string can be anything. It can be qt1, qt2.., qtA, qtB..,qta, qtb.. etc. Thats why i decided to use the Regex. I new to this and I set the pattern string like this:
String regex = '<span class=\"[a-z]{1}[a-z]{1}[A-Z]{1}\"';`
I dont know if it is right. I use the following code to test:
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(rTitle);
if (m.find()) {
System.debug('TITLE: ' + rTitle);
}
But, the code is not entering into the if
block. I am pretty sure that the pattern string is wrong. So, what modifications i have to do to make the pattern string right?