tags:

views:

139

answers:

3

Hi,

I am trying to write a regex to get the numbers from strings like these ones:

javascript:ShowPage('6009',null,null,null,null,null,null,null)
javascript:BlockLink('2146',null,null,null)

I am having difficulty writing the regex to grab these numbers.

Could anyone lend a hand?

Cheers

Eef

+3  A: 

Try this:

(\d+)

What language are you using to parse these strings? If you let me know I can help you with the code you would need to use this regular expression.

Andrew Hare
A: 

just match numbers: \d+

tanascius
+1  A: 

Assuming:

  • you want to capture the digits
  • there's only one set of digits per line

Try this:

/(\d+)/

then $1 (Perl) or $matches[1] (PHP) or whatever your poison of choice is, should contain the digits.

Jeremy Smyth