F
find clausen
How do i find the value next to width= (500)
in:
'"../graphics/press/012.jpg" width=500 height=339'
in:
'"../graphics/press/012.jpg" width=500 height=339'
var theString = '"../graphics/press/012.jpg" width=500 height=339';
var theWidth = parseInt(theString.substr(theString.indexOf('width=') + 6));
var theHeight = parseInt(theString.substr(theString.indexOf('height=') +
7));
Assuming that the number of digits in the width is not a certainty
(ie. could be 500 or 67 or 1005) then you can do it by splitting the
str = '"/graphics/press/012.jpg" width=500 height=339';
value = (str.match(/width=(\d+)/))[1];
alert(value);
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.