zoukankan
html css js c++ java
正则-匹配超链接地址及内容
今天做文章抓取程序的完善开发,碰到了以下问题
“<a href=aaa.html>A页</a><a href=bbb.html>B页</b>” 利用正则从中分别取出 aaa.html ,A页 ,bbb.html,B页。
自己写了俩正则 算是都能实现,但是是先匹配出所有的href对应的Html,再匹配出类似"A页"标题这段。 但是感觉很麻烦,从网上一搜,果然看到有位大侠写的正则很简炼,贴出记下,膜拜之
Code
1
MatchCollection mc
=
Regex.Matches(htmlstring,
@"
<a\s+href=(?<url>.+?)>(?<content>.+?)</a>
"
);
2
foreach
(Match m
in
mc)
3
{
4
url
=
m.Groups[
"
url
"
].Value;
5
6
content
=
m.Groups[
"
content
"
].Value;
7
}
其中htmlstring 为输入代码
查看全文
相关阅读:
使用mybatis如果类属性名和数据库中的属性名不一样取值就会为null
学习mybatis时出现了java.io.IOException: Could not find resource EmployeeMapper.xml
配置mybatis-config.xml出现过很诡异的现象
mybatis学习(一)
报错cannot be cast to javassist.util.proxy.Proxy
列车调度
三角形
土豪聪要请客(stol)
Jams倒酒(pour)
Data
原文地址:https://www.cnblogs.com/wfwup/p/1336133.html
最新文章
cplusplus.com
STL视频_02
分配释放内存??
引入头文件_两种形式的区别??
STL视频_01
STL视频_00
C++ 流操作符重载函数
python logging system
python编码
pyweb tutorial
热门文章
自动化测试工具
ant build.xml
linux sftp and unix ftp
linux sort排序命令
正则表达式元字符
使用Mybatis连接数据库时报错:org.apache.ibatis.exceptions.PersistenceException: ### Error updating database.
在oracle中插入数据报错:ORA-00984列在此处不允许
报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMapper is not known to the MapperRegistry.
mybatis引入dtd约束
发现project项目打红色感叹号的一种解决方案
Copyright © 2011-2022 走看看