Application of regular expressions in java

String str = "<img id=\"J_StandardCode_m\" data-src=\"https://pin.aliyun.com/get_img?dt=1444720913307\" class=\"check-code-img\" />" ;
Use the following code to get the link, there are two parentheses, take the second one
List<String> ls=new ArrayList<String>();
        Pattern pattern = Pattern.compile("<img id=\"J_StandardCode_m(.*?)data-src=\"(.*?)\"");
        Matches matches = pattern.matcher (managers);
        while(matcher.find())
            ls.add(matcher.group(2));
        return ls.get(0);



[ ] matches only the characters in square brackets
() grouping, and the characters in parentheses are treated as a whole.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326966765&siteId=291194637