Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.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
Regex 获取url中所有辅助路由的名称(以字母形式)_Regex_Angular_Angular Router - Fatal编程技术网

Regex 获取url中所有辅助路由的名称(以字母形式)

Regex 获取url中所有辅助路由的名称(以字母形式),regex,angular,angular-router,Regex,Angular,Angular Router,url如下所示 ), 在这种情况下,我需要从任何组件得到p1,p2,p3 我试图组合一个正则表达式,但在js控制台中,我失败了,但它工作正常 我得到路由器类的url let url = this.router.url; let partial = this.router.url.split ('(') [1] let regex = /(\w)*:/g let outlets = regex.exec(partial) console.log(outlets) // you do not ge

url如下所示

),

在这种情况下,我需要从任何组件得到p1,p2,p3

我试图组合一个正则表达式,但在js控制台中,我失败了,但它工作正常

我得到路由器类的url

let url = this.router.url;
let partial = this.router.url.split ('(') [1]

let regex = /(\w)*:/g
let outlets = regex.exec(partial)
console.log(outlets) // you do not get all the matches
我需要从任何组件获取所有二级插座的名称,我认为这样一来,我在正则表达式中遇到了问题


如果有其他方法可以得到我想要的东西,那将非常有用。

我建议对
字符和
/(?谢谢,如果equal有效,那么问题仍然存在,因为我想知道使用angular的本机类捕捉第二条路线的另一种方法,这使用正则表达式暂时为我服务。很公平:)我不是一个很有棱角的专家,所以我恐怕在这方面帮不了你,不过希望这在同时也足够了:P