regexp.js (4804B)
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 reUncPath = require( './main.js' ); 24 25 26 // MAIN // 27 28 /** 29 * Matches parts of a UNC path. 30 * 31 * Regular Expression: `/^\\\\([^\\:\|\[\]\/";<>+=,?* _]+)\\([\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,80})(((?:\\[\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,255})+?|)(?:\\((?:[\u0020-\u0021\u0023-\u0029\u002B-\u002E\u0030-\u0039\u003B\u003D\u0040-\u005B\u005D-\u007B]{1,255}){1}(?:\:(?=[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]|\:)(?:([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+(?!\:)|[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]*)(?:\:([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+)|))|)))|)$/` 32 * 33 * - `/^\\\\` 34 * - match a string that begins with two backward slashes `\\\\` 35 * 36 * - `()` 37 * - capture (1) (host name) 38 * 39 * - `[^\\:\|\[\]\/";<>+=,?* _]+` 40 * - match any sequence of characters, excluding `\\:\|\[\]\/";<>+=,?* _`, one or more times 41 * 42 * - `\\` 43 * - match a literal backward slash `\\` 44 * 45 * - `()` 46 * - capture (2) (share name) 47 * 48 * - `[\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,80}` 49 * - match any sequence of 1 to 80 characters matching `` !#$%'()\-\.0-9@A-Z^_`a-z{}~`` and Latin-1 Unicode supplement 50 * 51 * - `(` 52 * - begin capture (3) (object name) 53 * 54 * - `(` 55 * - begin capture (4) (path name) 56 * 57 * - `(?:\\[\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,255})+?` 58 * - capture but do not remember a `\\` literal followed by one or more sequences of 1 to 255 characters matching `` !#$%'()\-\.0-9@A-Z^_`a-z{}~`` and Latin-1 Unicode supplement and do so non-greedily (5) 59 * 60 * - `|)` 61 * - OR capture nothing (4) (path name) 62 * 63 * - `(?:` 64 * - begin capture but do not remember (6) 65 * 66 * - `\\` 67 * - match a `\\` literal 68 * 69 * - `(` 70 * - begin capture (7) (file name) 71 * 72 * - `(?:[0-9a-z]{1,255}){1}` 73 * - capture but do not remember a sequence of 1 to 255 characters matching `` !#$%'()\+,\-\.0-9;=@A-Z\[\]^_`a-z{`` (8) 74 * 75 * - `(?:` 76 * - begin capture but do not remember (9) 77 * 78 * - `\:(?=[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]|\:)` 79 * - match a literal `:` only if followed by `\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF` OR a literal `:` 80 * 81 * - `(?:` 82 * - begin capture but do not remember (10) 83 * 84 * - `([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+(?!\:)|[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]*)` 85 * - capture a sequence of one or more characters not followed by a literal `:`; otherwise, capture a sequence of 0 or more characters (11) (stream name) 86 * 87 * - `(?:` 88 * - begin capture but do not remember (12) 89 * 90 * - `\:` 91 * - match a literal `:` 92 * 93 * - `([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+)` 94 * - capture a sequence of one or more characters (13) (stream type) 95 * 96 * - `|)` 97 * - OR capture nothing (12) 98 * 99 * - `)` 100 * - end capture (10) 101 * 102 * - `|)` 103 * - OR capture nothing (9) 104 * 105 * - `)` 106 * - end capture (7) (file name) 107 * 108 * - `)` 109 * - end capture (6) 110 * 111 * - `|)` 112 * - OR capture nothing (3) (object name) 113 * 114 * - `$/` 115 * - end of string 116 * 117 * 118 * @constant 119 * @type {RegExp} 120 * @default /^\\\\([^\\:\|\[\]\/";<>+=,?* _]+)\\([\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,80})(((?:\\[\u0020-\u0021\u0023-\u0029\u002D-\u002E\u0030-\u0039\u0040-\u005A\u005E-\u007B\u007E-\u00FF]{1,255})+?|)(?:\\((?:[\u0020-\u0021\u0023-\u0029\u002B-\u002E\u0030-\u0039\u003B\u003D\u0040-\u005B\u005D-\u007B]{1,255}){1}(?:\:(?=[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]|\:)(?:([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+(?!\:)|[\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]*)(?:\:([\u0001-\u002E\u0030-\u0039\u003B-\u005B\u005D-\u00FF]+)|))|)))|)$/ 121 * @see [MSDN]{@link https://msdn.microsoft.com/en-us/library/gg465305.aspx} 122 */ 123 var RE_UNC_PATH = reUncPath(); 124 125 126 // EXPORTS // 127 128 module.exports = RE_UNC_PATH;