我需要采用单个cuote(或任何其他字符)中的单词:
从此 var theText="this is the 'text'";
我需要采用:“text”
,因为它是单个cuotes中的单词。
谢谢!
最佳答案
尝试RegExp :
var theText="this is the 'text'";
var reg = /'(.*)'/;
var res = reg.exec(theText); // res returns array => ["'text'", "text"]
console.log(res[1]); // returns text
关于javascript - 从单引号中的文本中获取单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22943079/