我有一個HTML字符串,並且想要提取特定標記<selection>
內的內容。正則表達式匹配模式php
例子:
Lorem Ipsum is simply <selection alt="dummy" name="dummy">dummy</selection > text the printing and typesetting <selection alt="industry" name="industry">industry</selection>. Lorem Ipsum has been the industry's <selection alt="standard" name="standard">standard</selection>dummy text ever since the 1500s.
在上面的HTML字符串我需要提取裏面selection
標籤文本,但所有的標籤都有不同的屬性。請幫助我解決方案。
爲什麼不使用html解析器? – 2014-12-02 12:16:14
這個'<(選擇)\ b [^ <>] *>([^ <>] *)<\/\1>'將適用於您當前的輸入。從組索引2獲取想要的字符串。 – 2014-12-02 12:17:36
嵌套在''標籤中的標籤是否可以嵌套?像' foo bar baz '? –
2014-12-02 12:19:41