Grabbing an number from a URL in Selenium IDE

I came across an issue during my testing where I had a URL that contained a company ID number that I would need later on in the testing. Here is how I ended up storing it:

URL: <a href=”/admin/companies/edit/6“>View</a>

I need the 6 from that URL to be stored as a variable called “companyid”.

First thing I did was store the URL:

storeAttribute | link=View@href | viewLink

Then to verify I had it right:

echo | ${viewLink} |

Now that I have the link stored, lets use some regex to pull the number out:

storeEval | new RegExp(‘([0-9]+)’).exec(‘${viewLink}’)[1] | companyid

And verify:

echo | ${companyid}

Hope that helps!