I have the following string : ‘user-status status-avail left top-pos‘.
I’d like to lookup this string searching for ‘status-something’ where something can have different forms like ‘busy’ ‘not_busy’ and return this specific string. How should I write my regex and should I use split or match for this task ?
I’ve tried :
str.match(/status-([a-z]+)/);
but I get :
["status-avail", "avail"] in return, and not only ‘status-avail’.
Remove the parentheses from your regex. (or just get the first item found)