time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

regexp.js (3410B)


      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 reDirnameWindows = require( './main.js' );
     24 
     25 
     26 // MAIN //
     27 
     28 /**
     29 * Regular expression to capture a Windows path dirname. Modified from Node.js [source][1].
     30 *
     31 * Regular expression: `/^((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+|)(?:[\\\/]|)(?:[\s\S]*?))(?:[\\\/]+?|)(?:(?:\.{1,2}|[^\\\/]+?|)(?:\.[^.\/\\]*|))(?:[\\\/]*)$/`
     32 *
     33 * -   `^`
     34 *     -   match any string which begins with
     35 *
     36 * -   `()`
     37 *     -   capture (includes the device, slash, and dirname)
     38 *
     39 * -   `(?:)`
     40 *     -   capture but do not remember (device)
     41 *
     42 * -   `[a-zA-Z]:`
     43 *     -   match any upper or lowercase letter and a `:` literal
     44 *
     45 * -   `|`
     46 *     -   OR
     47 *
     48 * -   `[\\\/]`
     49 *     -   match a `\` or `/` literal character
     50 *
     51 * -   `{2}`
     52 *     -   exactly two times
     53 *
     54 * -   `[^\\\/]+`
     55 *     -   match anything but a `\` or `/` literal one or more times
     56 *
     57 * -   `[\\\/]+`
     58 *     -   match a `\` or `/` literal one or more times
     59 *
     60 * -   `[^\\\/]+`
     61 *     -   match anything but a `\` or `/` literal one or more times
     62 *
     63 * -   `|)`
     64 *     -   OR capture nothing
     65 *
     66 * -   `(?:)`
     67 *     -   capture but do not remember (slash)
     68 *
     69 * -   `[\\\/]`
     70 *     -   match a `\` or `/` literal
     71 *
     72 * -   `|)`
     73 *     -   OR capture nothing
     74 *
     75 * -   `(?:)`
     76 *     -   capture but do not remember (dirname)
     77 *
     78 * -   `[\s\S]`
     79 *     -   match any space or non-space character
     80 *
     81 * -   `*?`
     82 *     -   zero or more times but do so non-greedily
     83 *
     84 * -   `(?:)`
     85 *     -   capture but do not remember (slash before basename)
     86 *
     87 * -   `[\\\/]+?`
     88 *     -   match a `\` or `/` literal one or more times, but do so non-greedily
     89 *
     90 * -   `|)`
     91 *     -   OR capture nothing
     92 *
     93 * -   `(?:)`
     94 *     -   capture but do not remember (basename)
     95 *
     96 * -   `(?:)`
     97 *     -   capture but do not remember
     98 *
     99 * -   `\.{1,2}`
    100 *     -   match a `.` literal one or two times
    101 *
    102 * -   `|`
    103 *     -   OR
    104 *
    105 * -   `[^\\\/]+?`
    106 *     -   match anything but a `\` or `/` literal one or more times, but do so non-greedily
    107 *
    108 * -   `|)`
    109 *     -   OR capture nothing
    110 *
    111 * -   `(?:)`
    112 *     -   capture but do not remember (extname)
    113 *
    114 * -   `\.`
    115 *     -   match a `.` literal
    116 *
    117 * -   `[^.\/\\]*`
    118 *     -   match anything but a `.`, `/`, or `\` literal zero or more times
    119 *
    120 * -   `|)`
    121 *     -   OR capture nothing
    122 *
    123 * -   `(?:)`
    124 *     -   capture but do not remember (trailing slash)
    125 *
    126 * -   `[\\\/]*`
    127 *     -   match a `\` or `/` literal zero or more times
    128 *
    129 * -   `$`
    130 *     -   end of string
    131 *
    132 * [1]: https://github.com/nodejs/node/blob/1a3b295d0f46b2189bd853800b1e63ab4d106b66/lib/path.js#L65
    133 *
    134 * @constant
    135 * @type {RegExp}
    136 * @default /^((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+|)(?:[\\\/]|)(?:[\s\S]*?))(?:[\\\/]+?|)(?:(?:\.{1,2}|[^\\\/]+?|)(?:\.[^.\/\\]*|))(?:[\\\/]*)$/
    137 */
    138 var RE_DIRNAME_WINDOWS = reDirnameWindows();
    139 
    140 
    141 // EXPORTS //
    142 
    143 module.exports = RE_DIRNAME_WINDOWS;