javascript - 从单引号中的文本中获取单词

标签 javascript jquery

我需要采用单个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

DEMO

关于javascript - 从单引号中的文本中获取单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22943079/

相关文章:

javascript - JScript - 如何知道脚本是使用 WSH 激活还是由另一个脚本内部激活?

javascript - JQuery - $(document).ready() 在元素加载之前执行

javascript - 如何使用翻转插件在悬停时切换图像

javascript - 如何使用 iframe 编写可调整大小的页面?

javascript - 如何使图像蒙版出现在悬停时

Javascript正则表达式看后面

javascript - jQuery-UI 对话框不会显示按钮

javascript - AngularJS 在编码正斜杠后附加链接 -

javascript - 使用 Javascript 检测两个字符串之间的差异

javascript - TypeError : element. summernote 不是函数