Regex (JS) - sjherrick/code-base GitHub Wiki
Regex (JS)
Extract Value
> x = 'Spam Eggs'
> reg =/(\w+)\s+Eggs/
>
> x.match(reg) // Match object
[
'Spam Eggs',
'Spam',
index: 0,
input: 'Spam Eggs',
groups: undefined
]
> x.match(reg)[0] // Whole string if match
'Spam Eggs'
> x.match(reg)[1] // Match value within first ()
'Spam'