Showing posts with label RegExp. Show all posts
Showing posts with label RegExp. Show all posts

Wednesday, September 27, 2017

Get int or float number from a string

Number("this a test (12.75%)".match(/\d*\.*\d+/g)[0]); // Output: 12.75

Wednesday, October 28, 2015

Extracts a word which starts with a given substring

// extracts js_* class
$(anySelector).attr('class').match(/\bjs_[^\b]*?\b/)[0];