View Single Post
Old 01-15-2013, 02:45 PM   PM User | #4
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 961
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Allows for x or the character you used between the numbers: × (Hex FFFD)

Code:
var str = "tumblr_mgn6mfe9aD1rbaz5bo1_500.jpg (500x705)",
    dims = str.match( /\((\d+)(?:\uFFFD|x)(\d+)\)/ ),
    width = 0, 
    height = 0;

if( dims )
{
  width = dims[ 1 ];
  height = dims[ 2 ];
  
  alert("Width=" + width + ", height=" + height );
}
Logic Ali is offline   Reply With Quote