作者lazcat (雷喵)
看板RegExp
标题[问题] 撷取特定区间中特定字
时间Fri Mar 12 23:08:16 2021
/*
听说注明使用的语言、环境
*
问题有可能较容易被解决...
*/
使用C#9.0
<p>apple is an apple</p>
<h1>apple is an apple</h1>
我想要取出<p></p>中的apple 并替换成其他字元
但不希望改到h1中的apple
查了一下能用
/(?<=<p>)(.*)(?=</p>)/
取出p中的apple is an apple
但是无法只取出其中的apple
或是能够取出所有的apple但不包含被h1 tag包围的apple更好
小弟正规菜鸡
先感谢各位大神
-----
Sent from JPTT on my iPhone
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 223.139.115.197 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/RegExp/M.1615561701.A.737.html
※ 编辑: lazcat (223.139.115.197 台湾), 03/12/2021 23:08:59
2F:→ lazcat: 虽然不是要爬虫 或分析html 还是谢谢回答 03/13 21:16
3F:→ lazcat: 找到非正规表达式的方法解决了 03/13 21:16