regexp.js (2897B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var reExtnameWindows = require( './main.js' ); 24 25 26 // MAIN // 27 28 /** 29 * Captures a Windows filename extension. Modified from Node.js [source][1]. 30 * 31 * - `^` 32 * - match any string which begins with 33 * 34 * - `(?:)` 35 * - capture but do not remember (device) 36 * 37 * - `[a-zA-Z]:` 38 * - match any upper or lowercase letter and a `:` literal 39 * 40 * - `|` 41 * - OR 42 * 43 * - `[\\\/]` 44 * - match a `\` or `/` literal character 45 * 46 * - `{2}` 47 * - exactly two times 48 * 49 * - `[^\\\/]+` 50 * - match anything but a `\` or `/` literal one or more times 51 * 52 * - `[\\\/]+` 53 * - match a `\` or `/` literal one or more times 54 * 55 * - `[^\\\/]+` 56 * - match anything but a `\` or `/` literal one or more times 57 * 58 * - `|)` 59 * - OR capture nothing 60 * 61 * - `(?:)` 62 * - capture but do not remember (slash) 63 * 64 * - `[\\\/]` 65 * - match a `\` or `/` literal 66 * 67 * - `|)` 68 * - OR capture nothing 69 * 70 * - `(?:)` 71 * - capture but do not remember (dirname) 72 * 73 * - `[\s\S]` 74 * - match any space or non-space character 75 * 76 * - `*?` 77 * - zero or more times but do so non-greedily 78 * 79 * - `(?:)` 80 * - capture but do not remember (basename) 81 * 82 * - `(?:)` 83 * - capture but do not remember 84 * 85 * - `\.{1,2}` 86 * - match a `.` literal one or two times 87 * 88 * - `|` 89 * - OR 90 * 91 * - `[^\\\/]+?` 92 * - match anything but a `\` or `/` literal one or more times, but do so non-greedily 93 * 94 * - `|)` 95 * - OR capture nothing 96 * 97 * - `()` 98 * - capture (extname) 99 * 100 * - `\.` 101 * - match a `.` literal 102 * 103 * - `[^.\/\\]*` 104 * - match anything but a `.`, `/`, or `\` literal zero or more times 105 * 106 * - `|)` 107 * - OR capture nothing 108 * 109 * - `(?:)` 110 * - capture but do not remember (trailing slash) 111 * 112 * - `[\\\/]*` 113 * - match a `\` or `/` literal zero or more times 114 * 115 * - `$` 116 * - end of string 117 * 118 * [1]: https://github.com/nodejs/node/blob/1a3b295d0f46b2189bd853800b1e63ab4d106b66/lib/path.js#L65 119 * 120 * @constant 121 * @type {RegExp} 122 * @default /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+|)(?:[\\\/]|)(?:[\s\S]*?)(?:(?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/ 123 */ 124 var RE_EXTNAME_WINDOWS = reExtnameWindows(); 125 126 127 // EXPORTS // 128 129 module.exports = RE_EXTNAME_WINDOWS;