java正则表达式匹配img路径
匹配src路径为http://img.baidu.com/hi/......(路径后面不固定),然后用replaceAll将该路径替换为空值将该路径所在的img标签替换为...
匹配src路径为http://img.baidu.com/hi/......(路径后面不固定),然后用replaceAll将该路径替换为空值
将该路径所在的img标签替换为空值,上面说错了 展开
将该路径所在的img标签替换为空值,上面说错了 展开
2个回答
展开全部
package table;
public class FileTester
{
public static void main ( String[] args )
{
String reg = "(src[\\=\\s\'\"]+)http\\:\\/\\/img\\.baidu\\.com\\/hi\\/[^\'\"]+([\'\"])";
String url = "sdfsdf<img src='https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/hi/we.com' />sdf<img src='https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/hi/we.com' />sf'";
url = url.replaceAll (reg, "$1$2");
System.out.println (url);
}
}
public class FileTester
{
public static void main ( String[] args )
{
String reg = "(src[\\=\\s\'\"]+)http\\:\\/\\/img\\.baidu\\.com\\/hi\\/[^\'\"]+([\'\"])";
String url = "sdfsdf<img src='https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/hi/we.com' />sdf<img src='https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/hi/we.com' />sf'";
url = url.replaceAll (reg, "$1$2");
System.out.println (url);
}
}
展开全部
Regexp.Replace(input, @"(?i)<img\s+((?!src).)*src\s*=\s*['"]?https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/hi/((?!/>).)*/>", "");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询