-1

HTML:

<input name="__CUTE" id="__CUTE" value="/dfdjksfhnvdj9326r" type="hidden">

If need the entire page I will update the post

The only thing I know is that its needs to be with preg_match:

preg_match('/value="([^"]+)"/'...
waylan
  • 15
  • 1
  • 4
  • What are you even trying to extract and what u are trying to do , explain it better please. – Frosty Jan 07 '18 at 10:56
  • 1
    Just change word for value in your preg_match regex – jeprubio Jan 07 '18 at 10:57
  • @Innervisions im trying to extract the value inside the input __CUTE, Then view it through echo. – waylan Jan 07 '18 at 11:05
  • @jeprubio But it will extract all the values that is on the page right? I want only what in the CUTE input – waylan Jan 07 '18 at 11:06
  • Give me an example what inside __CUTE needs to be extract/replaced – Frosty Jan 07 '18 at 11:10
  • That seems to be XML, so use an XML parser. Of course, you could use regular expressions, but I'm pretty sure I could come up with valid and equivalent XML that your regular expressions won't cover, because it's either overcomplicated or brittle. – Ulrich Eckhardt Jan 07 '18 at 11:10
  • @Innervisions its very long value so i cut half: /wEPDwUKMTEzMTQ2NjgyOA8WAh4PaG9uZXlwb3RWZXJzaW9uBQI0NxYCZg9kFgYCAQ9kFgICGw9kFgICAQ8WAh4EVGV4dGVkAgUPZBYSAgEPFgIeB1Zpc2libGVnFgICAQ8PFgQfAQUDMTAxHgdUb29sVGlwBRRiYWxhbmNlOiAxMDEgc2F0b3NoaWRkAgMPFgIfAmdkAgUPFgIfA – waylan Jan 07 '18 at 11:18
  • @UlrichEckhardt Yes, a little complicated. I've attached a response above – waylan Jan 07 '18 at 11:20

1 Answers1

0

I would use DOMDocument for this but since you want to use a regexp expression:

$res = preg_match('/<input name="__CUTE" (.*?) value="([^"]+)"/s', $html, $matches);

And get the value of the second match only.

In case you want to use DOMDocument:

$dom = new DomDocument();
$dom->loadHTML($html);

$cute = $dom->getElementById("__CUTE");
echo $cute->getAttribute('value');
jeprubio
  • 17,312
  • 5
  • 45
  • 56
  • Works for me with a DOM better :) Thanks a lot! But how do i make it pull just one line? its gives me 4 lines – waylan Jan 07 '18 at 11:28
  • Do you mean new DomDocument()->loadHTML($html)->getElementById("__CUTE")->getAttribute('value') ? – jeprubio Jan 07 '18 at 11:38
  • I fixed the warnings with the help of this post: https://stackoverflow.com/questions/1685277/warning-domdocumentloadhtml-htmlparseentityref-expecting-in-entity thank you:) – waylan Jan 07 '18 at 12:00