[英]Node.js Path module source two regular express
我对node.js路径模块源中的2个正则表达式感到困惑
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
剂量splitTailRe如何工作? 与该组最混淆的: "((?:\\.{1,2}|[^\\\\\\/]+?|)(\\.[^.\\/\\\\]*|))"
这可能对您有所帮助
splitDeviceRE = https://regex101.com/r/mV5gS0/2
splitTailRe = https://regex101.com/r/mV5gS0/1
它分解了您输入的正则表达式,并逐步解释了正则表达式的每个“部分”在做什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.