Trey Copeland
Trey Copeland

Reputation: 3527

Regular expression to grab value from parameter

I need to write a regular expression to grab just the values from the articleid parameter. (ie. 2689615). I have a good start: [0-9] but just don't know where to go from there. Basically, I need something to grab values between 'articleid=' and '">'

   <strong>Name</strong>
    <li><a href="detail.aspx?articleid=2689615">Id 1</a></li>
    <li><a href="detail.aspx?articleid=2689723">Id 2</a></li>
    <li><a href="detail.aspx?articleid=2689831">Id 3</a></li>
    <li><a href="detail.aspx?articleid=2690137">Id 4</a></li>
    <li><a href="detail.aspx?articleid=2690713">Id 5</a></li>

Upvotes: 1

Views: 85

Answers (3)

renevanderark
renevanderark

Reputation: 995

Capture:

/articleid=([^\"]+)/

This captures everything between the equals and the double quote...

I always use: http://rubular.com/

Upvotes: 3

SERPRO
SERPRO

Reputation: 10067

If you know the parameter name and the value is just numbers:, this should work:

   articleid=([0-9]+)

Upvotes: 0

jro
jro

Reputation: 9474

Depends on the language you're using, but articleid=(\d+) should do.

Upvotes: 4

Related Questions