-3
我有以下問題:我有一些HTML代碼,我需要獲取標籤內容。我不想使用數百萬個子字符串或類似的東西。我想使用正則表達式,但我有與過濾標籤類,ids,或沒有任何問題的問題。這裏是我的正則表達式:Python的正則表達式得到標籤內容沒有標籤名稱
match = re.search('(?<=<span(.+)?>)(.*)(?=</span>)', '<span class="red">color</span>')
的Python會引發以下錯誤
sre_constants.error: look-behind requires fixed-width pattern
我想從幫助從
<span class="red">color</span>
,並獲得內容從
<span>color</span>
謝謝大家!
[RegEx match open tags not except XHTML self-contained tags](http://stackoverflow.com/questions/ 1732348/regex-match-open-tags-except-xhtml-self-contained-tags) – arco444
*爲什麼*人們堅持使用正則表達式來解析HTML? –
你必須使用正則表達式嗎?爲什麼不是像美麗湯 – Tobey