从单个cuotes中的文本中获取单词

Za7*_*7pi 0 javascript jquery

我需要接受单个cuote(或任何其他角色)中的单词:

从这个var theText="this is the 'text'"; 我需要采取:"text"因为是单个cuotes中的单词.

谢谢!

nan*_*ash 5

试试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)

DEMO