使用jQuery从2个字符串之间提取字符串 [英] Extract String from between 2 Strings with Jquery
本文介绍了使用jQuery从2个字符串之间提取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Jquery或Javascript从下面的字符串中提取" inc/funcs.asp ".
How do I extract 'inc/funcs.asp' from the string below, with Jquery or Javascript.
<script>
var str = '<!-- #include file="inc/funcs.asp" -->';
</script>
我想模式必须从寻找'#include file ='开始
I imagine the pattern must start with looking for '#include file="'
推荐答案
您可以使用此正则表达式:
You can use this regex:
/file="([^"]+)/
并抓取捕获的#1组
代码:
var fval = (str.match(/file="([^"]+)/) || ['', ''])[1];
这篇关于使用jQuery从2个字符串之间提取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文