Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串,例如“hello word:abc there”
我需要在值'word:'之后获取值,所以在上述情况下,答案将是'abc'。
"abc xyz 字:2 hhh yyy" = '2'
等等
一种方法是使用正则表达式
使用这个正则表达式:
var yourString="hello word:1235 tsfa"; var patt1=/:(\w*)/; alert(yourString.match(patt1)[1]);
工作的jsFiddle