Get dimensions from text

I have a string that looks similar to this:

tumblr_mgn6mfe9aD1rbaz5bo1_500.jpg (500×705)

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?

Hi there,

The following reg-ex matches a bracket, at least one number, an ‘x’, at least one number and a closing bracket.

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

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)