Created
June 9, 2016 05:26
-
-
Save moltak/b8bad1ea94195f823e2324ce87de9c49 to your computer and use it in GitHub Desktop.
Http image tag extractor using regular expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpImageTagExtractor { | |
public static List<String> extract(String text) { | |
//regular expression for extract image tag | |
Pattern pattern = Pattern.compile("<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>"); | |
Matcher matcher = pattern.matcher(text); | |
List<String> lists = new ArrayList<>(); | |
while(matcher.find()) { | |
lists.add(matcher.group(1)); | |
} | |
return lists; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Junit test code