简体   繁体   English

Node.js Path模块源码两个常规表达

[英]Node.js Path module source two regular express

I am confused with 2 regex in the node.js path module source 我对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}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;

How dose splitTailRe work? 剂量splitTailRe如何工作? most confused with the group: "((?:\\.{1,2}|[^\\\\\\/]+?|)(\\.[^.\\/\\\\]*|))" 与该组最混淆的: "((?:\\.{1,2}|[^\\\\\\/]+?|)(\\.[^.\\/\\\\]*|))"

This may be of some help to you 这可能对您有所帮助

splitDeviceRE = https://regex101.com/r/mV5gS0/2 splitDeviceRE = https://regex101.com/r/mV5gS0/2

splitTailRe = https://regex101.com/r/mV5gS0/1 splitTailRe = https://regex101.com/r/mV5gS0/1

It breaks down the regex you feed it and explains step by step what each 'section' of Regex is doing. 它分解了您输入的正则表达式,并逐步解释了正则表达式的每个“部分”在做什么。

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

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