-2

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"/>

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

user756476
  • 83
  • 1
  • 1
  • 9
  • 1
    In what programming language? – DarkLightA Jun 10 '11 at 12:46
  • 1
    *"…using REGEX only…"* - Do you also have a good explanation why regex is your only option? – Tomalak Jun 10 '11 at 12:48
  • possible duplicate of [Get name and value from the input tag](http://stackoverflow.com/questions/2926597/get-name-and-value-from-the-input-tag), or [this](http://stackoverflow.com/questions/1058852/regex-to-get-src-value-from-an-img-tag) – Grant Thomas Jun 10 '11 at 12:48
  • 2
    http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – Shawn Chin Jun 10 '11 at 12:51

3 Answers3

2

RegExp:

<input [^>]*?value="([^"]*)"
Kirill Polishchuk
  • 54,804
  • 11
  • 122
  • 125
0

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

Pattern:

<input [^>]*? value="(.*)"
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
-1

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

Community
  • 1
  • 1
Francis Gilbert
  • 3,382
  • 2
  • 22
  • 27