Given an HTML string like:
<span class="findme" id="31313131313">The Goods</span>
What kind of REGEX in Coldfusion would return just (if it's even possible?): 31313131313
Thanks!
Given an HTML string like:
<span class="findme" id="31313131313">The Goods</span>
What kind of REGEX in Coldfusion would return just (if it's even possible?): 31313131313
Thanks!
It is not a good idea to parse html using regex in general. Use an html parser instead.
That said, the following regex will give you the id from the given string.
<span[^>]*id="(\d+)"
The first group of the match, $1
, will contain 31313131313
.
It assumes a numeric id. For alphanumeric ones, replace \d
with [0-9a-zA-Z]
. You can use \w
if _
is fine too.
Try, <span[^>]+?id="([^"]+)".*
According to your comment in Amarghosh answer, that would be
<cfset uniqueID = rereplace(results[i],'<span[^>]+?id="([^"]+)".*',"\1")>