-6
大家好,我需要解析我的textarea才能得到所有单词(后跟空格),它有一个$
作为前缀。正则表达式得到单词
例如,我有follwing文本:
my name is $Ahmad and I wish $peace to all the $world
现在我需要extraxt $Ahmad
和$peace
,而不是$world
(因为它没有空格后面)。
大家好,我需要解析我的textarea才能得到所有单词(后跟空格),它有一个$
作为前缀。正则表达式得到单词
例如,我有follwing文本:
my name is $Ahmad and I wish $peace to all the $world
现在我需要extraxt $Ahmad
和$peace
,而不是$world
(因为它没有空格后面)。
var matches = str.match(/\B\$[^ ]+(?=)/g);
这里的小提琴:http://jsfiddle.net/fpjZX/
附:假设你的意思是JavaScript ...
是它的JavaScript –
[你有什么尝试?](http://whathaveyoutried.com)如果你不打算表现出任何努力,为什么我应该?另外,你的意思是Java或JavaScript?两者不一样。 –
我做了很多尝试和它的JavaScript 这里是我的尝试 \ $ [a-z0-9&-_] + []但它不工作 –