我需要接受单个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
Run Code Online (Sandbox Code Playgroud)