Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Javascript中使用正则表达式获取RSS/XML标记之间的文本_Xml_Regex_Json_Rss - Fatal编程技术网

在Javascript中使用正则表达式获取RSS/XML标记之间的文本

在Javascript中使用正则表达式获取RSS/XML标记之间的文本,xml,regex,json,rss,Xml,Regex,Json,Rss,我正在创建一个jQuery移动应用程序,它解析RSS提要并将条目动态输入DOM。我正在使用.contentSnippet功能从..中抓取第一句或第二句,我希望内容介于..之间。如何使用Javascript和正则表达式选择此内容?下面是我正在使用的RSS的外观 美国银行家杂志(03/13)节,格伦… 我将提要作为JSON对象引入。如果您确定要使用正则表达式,可以使用 var str = '<description><![CDATA[<font size="2"><

我正在创建一个jQuery移动应用程序,它解析RSS提要并将条目动态输入DOM。我正在使用
.contentSnippet
功能从
..
中抓取第一句或第二句,我希望内容介于
..
之间。如何使用Javascript和正则表达式选择此内容?下面是我正在使用的RSS的外观

美国银行家杂志(03/13)节,格伦…


我将提要作为JSON对象引入。

如果您确定要使用正则表达式,可以使用

var str = '<description><![CDATA[<font size="2"><em>American Banker Magazine (03/13) Fest, Glen</em>...</description>',
    m = str.match( /<em>(.+?)<\/em>/ );

console.log( m && m[1] || 'Nothing doing' );
// American Banker Magazine (03/13) Fest, Glen
var str='American Banker Magazine(03/13)Fest,Glen…',
m=str.match(/(.+?)/);
console.log(m&&m[1]| |“无所事事”);
//《美国银行家》杂志(03/13)节,格伦

读一下这个。不要使用正则表达式,而是使用XML解析器,类似的问题:
http://stackoverflow.com/questions/5227592/extract-cdata-from-rss-xml-using-javascript