I have some text in different formats within my DOM body like this
(min-width: 400px)
(max-width : 500px)
(min-width :600px)
( max-width:700px )
I want to detect only digits from these formats & return them in to array
I tried
document.write($('body').text().match(/ *\([^)\d+]*\) */g, ""));
But it returns null. What I’m doing wrong ?
Here is fiddle : http://jsfiddle.net/gQHT2/1/
What you can do is using the following regexp:
This will match a
(, any non-number garbage, the number itself withpxappended, any spaces and a trailing). The number is grouped (enclosed with()), so that you can get the result separately if you useregexp.exec: http://jsfiddle.net/gQHT2/9/.