I am being fed a url that looks like this:
http://hamilton.kijiji.ca/c-buy-and-sell-sports-bikes-Kids-bike-W0QQAdIdZ215282410
I want to pull out the numbers after adIdZ
How can I pull these numbers 开发者_StackOverflow社区off dynamically?
s= 'http://hamilton.kijiji.ca/c-buy-and-sell-sports-bikes-Kids-bike-W0QQAdIdZ215282410'
s = s.replace( /\d+$/, '' )
Updated
s = 'http://hamilton.kijiji.ca/c-buy-and-sell-sports-bikes-Kids-bike-W0QQAdIdZ215282410'
s = s.match( /(\d+)$/ )
if ( s.length )
alert( s[1] )
Can't you just get the 8 last characters from the URL string?
It's not entirely clear what you want to achieve. If you wish to strip, that is remove, the final id, meder gave the correct reply. If you wish to extract the id, it's a simple change from his code:
s= 'http://hamilton.kijiji.ca/c-buy-and-sell-sports-bikes-Kids-bike-W0QQAdIdZ215282410'
id = s.match(/\d+$/)
精彩评论