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.
如果您的输入定义得很好(6个单词,需要获取第三个单词),为什么不只使用字符串方法:
'Assigned to ram on 2010-04-22 12:30:13.0'.split(' ')[2]
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"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.