作者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://www.ptt.cc/bbs/RegExp/M.1615561701.A.737.html
※ 編輯: lazcat (223.139.115.197 臺灣), 03/12/2021 23:08:59
→ lazcat: 雖然不是要爬蟲 或分析html 還是謝謝回答 03/13 21:16
→ lazcat: 找到非正規表達式的方法解決了 03/13 21:16