Issue
I migrated my project from Eclipse to Android Studio and everything worked fine. In this project I have a Regex which should find all image urls in a json-object I get from an API.
This is the Regex I have:
Pattern pattern = Pattern.compile("https?:\\/\\/[^\"]*?\\.(png|jpe?g|img)");
Matcher matcher = pattern.matcher(obj.toString());
while(matcher.find()) {
ImageBackgroundFetcher.getInstance(mActivity).addImageToLoadingQueue(matcher.group());
}
obj is the JSONObject I have with the image urls. It looks like the following and I would like to extract the url of the image (the bold marked part) {"image":"http:\/\/www.test.de\/media\/2015\/01\/16\/bildtitel.jpg"}
After I migrate the project from Eclipse to Android Studio this Regex isn't working any longer. The matcher.find()-Method did not return true and Android Studio gives me a warning in the code at the regex part "\\/\\/" where it says "redundant character escape"
I already googled but didn't find a solution. Any ideas how to solve the problem would be great, thanks in advance ;)
Solution
Okay, I am able to solve this issue. The correct regex is:
https?:\\\\/\\\\/[^\"]*?\\.(png|jpe?g|img)
Answered By - jennymo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.