[英]Can somebody please tell me where the error is in my regex line?
I've figured out this pattern: 我已经弄清楚了这种模式:
(?<=module.exports = function routes\(\) {\n)[\S\s]*?(?=\n})
to select the text inside the curly braces in this text: 在该文本的大括号内选择文本:
module.exports = function routes() {
this.root('pages#main');
this.get('/dashboard', 'pages#dashboard');
}
Will somebody please teach me why this is invalid?: 有人可以教我为什么这无效吗:
myVar = data.match(/(?<=module.exports \= function routes\(\) {\n)[\S\s]*?(?=\n})/);
if toString()
works in your context then this should work also 如果
toString()
在您的上下文中起作用,那么这也应该起作用
var str = module.exports.toString();
str = str.replace(/function [^ ]+\(\)\s*\{/, '').replace(/\}$/,'');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.