开发者

Regex: HTML, contents

开发者 https://www.devze.com 2023-03-12 04:40 出处:网络
I\'m having a little issue with getting a value of field in HTML using regex. There is a input tag in the html which is unique and here it is below.

I'm having a little issue with getting a value of field in HTML using regex.

There is a input tag in the html which is unique and here it is below.

<input type="hidden" name="t" value="I-WANT-TO-GET-THIS"/>
开发者_C百科

I would like to know, using REGEX only, how to get "I-WANT-TO-GET-THIS" (without quotes).

Thank-you very much for your time Paul


RegExp:

<input [^>]*?value="([^"]*)"


See an working example here: http://www.rubular.com/r/mG8AYSd5A1

Pattern:

<input [^>]*? value="(.*)"


How are you doing this? The best idea is to use a HTML parser. Regex with HTML has its own issues, see the link: RegEx match open tags except XHTML self-contained tags

0

精彩评论

暂无评论...
验证码 换一张
取 消