You could use regexp-match*
along with capturing groups and string->number
to extract the information from your string:
> (map string->number
(regexp-match* #px"data-symbol='(\\d+)'"
"data-symbol='1'
data-symbol='2'
data-symbol='3'
data-symbol='4'"
#:match-select second))
'(1 2 3 4)
The regexp-match*
function finds all matches of a regular expression in a given string, and #:match-select
is used to pick which capture group(s) to return in the result. Then string->number
is used to convert each element of the match to a numeric value.
Be careful, though: it looks like you might be trying to parse HTML with regular expressions, and as was (in)famously noted on this very site, that way leads only to madness. Consider using one of Racket’s HTML parsing libraries instead.