import java.util.regex.Matcher; import java.util.regex.Pattern; public class aa { public static void main(String[] args) { String htmlStr = "<img src=‘http://1231//1231/123/123.jpg‘ alt=‘图片‘>"; Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(htmlStr); String filePath = ""; while(m.find()) { filePath = m.group(1); } System.out.println(filePath); System.out.println(filePath.substring(filePath.lastIndexOf("/")+1,filePath.length()-1)); } }
原文地址:https://www.cnblogs.com/zzlcome/p/11106440.html
时间: 2024-10-07 21:49:21