CONTEXT
Supposing the following HTML
....
<p>Whatever</p>
<div>Whatever DIV78232 Everwhat</div>
....
Question:
How could I return a plain text string containing DIVnnnnn
, where nnnnn represents any digits.
My investigation so far:
The xPath replace() function will replace a pattern found inside the current DOM.
replace(.,'.*?(DIV\d+).*','$1') => DIV78232
Why am I blocked?
Because I want the query to return the "DIV78232" as a string, without actually replacing it in the DOM at all, just as it would return "Whatever" for the query /p/text()
[I am trying all this on the FirePath firefox-extension]
Note: According to the official DOCS
"replace() Returns the value of the first argument with every substring matched by the regular expression that is the value of the second argument replaced by the replacement string that is the value of the third argument."
FINAL PURPOSE:
My final purpose is to get the (string) IMAGE URL that matches '.*?image:.*?"(.+?)".*'
from this (which is inside the HTML):
In this case, the query //*[matches(.,'.*?image:.*?"(.+?)".*','i')]
returns the whole node, but I only want the first Capturing Group, which would be the IMAGE URL.
<script>...vp&output=xml_vast2&unviewed_position_start=1&
url='+encodeURIComponent(location.href)+'
description_url='+encodeURIComponent(location.href)+'&
image: "https://domain.com/xxxxxxx/public_images/2015.12/article/56797be1c46188ac438b45c3.jpg", // stretching: 'fi..</script>