I need to extract text but some parts are dynamic and change
This is my var
htts://query1.data.site.com/v7/finance/download/MYTEXT?period1=1664641287&period2=1696177287&interval=1d&events=history&includeAdjustedClose=true
I need to take only MYTEXT
These values changes
MYTEXT
1664641287
1696177287
1d
I tried with string.replace
but I don’t know how to remove the dynamic parts
The solution I thought of was to remove all the text before and after MYTEXT but I can’t write a command that can do this
2
Answers
Use a regexp that matches everything between the last
/
and?
Use
URL
to parse URL strings.You can get the
pathname
to extractMYTEXT
, which will be the last segment separated by/
‘s.You can get the
searchParams
to retrieve the value of specific query parameters likeperiod1=1664641287