两组正则表达式的单一结果?
Single result from two group Regular Expression?
我想从以下字符串(HTML 标签)中获取 单个 值。
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="6857842162548399092:-3372646398158034589" autocomplete="off" />
或
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[9028765775789786807:-4669779095536779687]]></update>
对于<input>
标签,表达式为
<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="[^"]+".*\/>
对于<update>
标签,表达式为
<update .*><!\[CDATA\[(.*?.*)\]\]><\/update>
需要单个结果 685784..89
或 90287..87
.
表达式必须得到 <input ...>
或 <update....>
的单一结果。
您可以将两者结合起来 |
("OR").
假设 PCRE 正则表达式风格:
(?|(?:<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="(?<value>[^"]+)".*\/>)|(?:<update .*?><!\[CDATA\[(?<value>.*?)\]\]><\/update>))
我想从以下字符串(HTML 标签)中获取 单个 值。
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="6857842162548399092:-3372646398158034589" autocomplete="off" />
或
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[9028765775789786807:-4669779095536779687]]></update>
对于<input>
标签,表达式为
<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="[^"]+".*\/>
对于<update>
标签,表达式为
<update .*><!\[CDATA\[(.*?.*)\]\]><\/update>
需要单个结果 685784..89
或 90287..87
.
表达式必须得到 <input ...>
或 <update....>
的单一结果。
您可以将两者结合起来 |
("OR").
假设 PCRE 正则表达式风格:
(?|(?:<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="(?<value>[^"]+)".*\/>)|(?:<update .*?><!\[CDATA\[(?<value>.*?)\]\]><\/update>))