javascript - Optional ending capture group -
i'm trying have 3 total capture groups last optional. i'm running issue i'm not sure how exclude last delimiter last group , have end.
here's pattern
/(.+)\@(.+)\:(.+)/
here's example strings
test@hello // => ['test', 'hello'] test@hello:optional // => ['test', 'hello', 'optional']
use string.split
string.split(/[:@]/)
[:@]
matches colon or @
symbol split function splits string according matched chars.
var s = 'test@hello:optiona' alert(s.split(/[@:]/))
or
var s = 'test@hello:optiona' alert(s.match(/[^@:]+/g))
Comments
Post a Comment