i have a string like following:
Assigned to ram on 2010-04-22 12:30:13.0
i need to extract the third word (ram). I tried the below regex, its not working.
/\s[a-zA-Z]*\s/
any help to fix this would be greatly appreciated.
i have a string like following:
Assigned to ram on 2010-04-22 12:30:13.0
i need to extract the third word (ram). I tried the below regex, its not working.
/\s[a-zA-Z]*\s/
any help to fix this would be greatly appreciated.
Try
a = "Assigned to ram on 2010-04-22 12:30:13.0"
re = /\w+\W+\w+\W+(\w+)/
alert(a.match(re)[1])
Instead of using a regular expression, why not just split the string on spaces and grab the third one?
var s = "Assigned to ram on 2010-04-22 12:30:13.0";
var third = s.split(/\s+/)[2];
// third will be "ram"
If your input is so well defined (6 words, need to get third), why not just use string methods:
'Assigned to ram on 2010-04-22 12:30:13.0'.split(' ')[2]