写出正则表达式,从一个字符串中提取链接地址。比如下面字符串中
“IT面试题博客中包含很多软件测试面试题”
则需要提取的地址为
“www.mianwww/html/category/it-interview/softwaretest ”
import Matcher;
import Pattern;
public class Regex {
static void url() {
String input = “IT面试题博客中包含很多软件测试面试题“;
Pattern pattern;
Matcher matcher;
pattern = Patternpile(“<a(?: [^>]*)+href=([^ >]*)(?: [^>]*)*>”); matcher = pattern.matcher(input);
while (matcher.find()) {
System.out.up());
正则匹配超链接}
}
public static void main(String[] args) {
url();
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论