I am trying to extract a substring matching a given pattern from a string in Javascript. Example:
var classProp = 'active category_games',
match = classProp.match(/category_[a-z]+\b/),
category;
if(match !== null && match.length > 0){
category = match[0];
}
Is there an easier way to achieve this? One liner, preferably?
source
share