I found the following regex in one of the Android Source file:
String regex = "\\s+(?i)src=\"cid(?-i):\\Q" + attachment.mContentId + "\\E\"";
if(string.matches(regex)) {
Print -- Matched
} else {
Print -- Not Found
}
NOTE: attachment.mContentId will basically have values like [email protected]
I made a sample code as below:
String content = "Hello src=\"cid:[email protected]\" is present";
String contentId = "[email protected]";
String regex = "\\s+(?i)src=\"cid(?-i):\\Q" + contentId + "\\E\"";
if(content.matches(regex))
System.out.println("Present");
else
System.out.println("Not Present");
This always gives "Not Present" as output.
But when I am doing the below:
System.out.println(content.replaceAll(regex, " Replaced Value"));
And the output is replaced with new value. If it is Not Present, then how could replaceAll work and replace the new value? Please clear my confusions.
Can anybody say what kind of content in string will make the control go to the if part?