简体   繁体   English

正则表达式工作在C#中,但不能在JavaScript中使用

[英]Regex working in C# but not in javascript

Can anyone help getting a piece of regex working in javascript please? 任何人都可以帮助获取正则表达式在javascript中工作吗?

This is the regular expression: 这是正则表达式:

storify.com\/*(?<code>[^"]*)

It works fine in C# but I can't get it working in js, I presume due to a delimiter issue but not sure which characters are causing the problem. 它在C#中可以正常工作,但是我无法在js中使用它,我想是由于定界符问题,但不确定是哪个字符引起了问题。

This is the js I'm trying but gives me and an "invalid quanitifier" error on the first line 这是我正在尝试的js,但是在第一行中给了我一个“无效的量化”错误

var myregex = /storify.com\/*(?<code>[^"]*)/;
var storify = 'http://storify.com/DigitalFirst/ces-2013-five-things-you-missed-day-3';
var remoteid = storify.match(myregex);
console.log(remoteid);

Thanks in advance for anyone who can help get this working. 预先感谢任何可以帮助您完成此工作的人。

JavaScript regexes have no suport for named captures (?<xxx>...) , that is why. JavaScript正则表达式不支持命名捕获(?<xxx>...) ,这就是为什么。

More details here (note: JavaScript is referred to as ECMA [262, to be precise]). 这里有更多详细信息(请注意:JavaScript被称为ECMA [准确地说是262])。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM