I have a string that looks similar to this:
I want to strip the text until I get the value 500 & 705. I want them as two separate values. How can I do this in javascript?Code:tumblr_mgn6mfe9aD1rbaz5bo1_500.jpg (500×705)
| SitePoint Sponsor |
I have a string that looks similar to this:
I want to strip the text until I get the value 500 & 705. I want them as two separate values. How can I do this in javascript?Code:tumblr_mgn6mfe9aD1rbaz5bo1_500.jpg (500×705)

Hi there,
The following reg-ex matches a bracket, at least one number, an 'x', at least one number and a closing bracket.
Code JavaScript:var str="tumblr_mgn6mfe9aD1rbaz5bo1_500.jpg (500x705)"; var match=str.match(/\((\d+)x(\d+)\)/); console.log(match[1]); console.log(match[2]);
Outputs:
500
705
HTH
How well do you know your JavaScript from your jQuery?
Check out SitePoint's latest JavaScript challenge
My blog
I forgot to say that the × is an ascii character and it's not the regular 'x' so your code doesn't work with the ASCII '×'

Hey,
Just replace the x with . (i.e. a single dot)
How well do you know your JavaScript from your jQuery?
Check out SitePoint's latest JavaScript challenge
My blog
Bookmarks