2016-08-22 28 views
0

我很困惑與2正則表達式Node.js的路徑模塊源Node.js的路徑模塊源的兩個正規快件

// 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}|[^\\\/]+?|)(\.[^.\/\\]*|))"

+0

'splitTailRe'正則表達式的解釋[here](https://regex101.com/r/eA1uF1/1)。 (進一步參考:http://www.regular-expressions.info/tutorial.html。) – nnnnnn

+0

或[regexper](https://regexper.com/#%5E(%5B%5Cs%5CS%5D *%3F )((%3F%3A%5C。%7B1%2C2%7D%7C%5B%5E%5C%5C%5C%2F%5D%2B%3F%7C)(%5C。%5B%5E。%5C %2F%5C%5C%5D *%7C))(%3F%3A%5B%5C%5C%5C%2F%5D *)%24)非常好。如果你還不明白,我不介意提交一個解釋。 – Whothehellisthat

回答