time-to-botec

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

README.md (2621B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Filename Extension
     22 
     23 > [Regular expression][regexp] to capture a Windows filename extension.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var reExtnameWindows = require( '@stdlib/regexp/extname-windows' );
     31 ```
     32 
     33 #### reExtnameWindows()
     34 
     35 Returns a [regular expression][regexp] to capture a Windows filename extension.
     36 
     37 ```javascript
     38 var RE_EXTNAME_WINDOWS = reExtnameWindows();
     39 var ext = RE_EXTNAME_WINDOWS.exec( 'index.js' )[ 1 ];
     40 // returns '.js'
     41 ```
     42 
     43 #### reExtnameWindows.REGEXP
     44 
     45 [Regular expression][regexp] to capture a Windows filename extension.
     46 
     47 ```javascript
     48 var ext = reExtnameWindows.REGEXP.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
     49 // returns '.js'
     50 ```
     51 
     52 </section>
     53 
     54 <!-- /.usage -->
     55 
     56 <section class="notes">
     57 
     58 ## Notes
     59 
     60 -   When executed against dotfile filenames (e.g., `.gitignore`), the [regular expression][regexp] does **not** capture the basename as a filename extension.
     61 
     62     ```javascript
     63     var ext = reExtnameWindows.REGEXP.exec( '.bash_profile' )[ 1 ];
     64     // returns ''
     65 
     66     ext = reExtnameWindows.REGEXP.exec( '.travis.yml' )[ 1 ];
     67     // returns '.yml'
     68     ```
     69 
     70 </section>
     71 
     72 <!-- /.notes -->
     73 
     74 <section class="examples">
     75 
     76 ## Examples
     77 
     78 <!-- eslint no-undef: "error" -->
     79 
     80 ```javascript
     81 var reExtnameWindows = require( '@stdlib/regexp/extname-windows' );
     82 
     83 var RE_EXTNAME_WINDOWS = reExtnameWindows();
     84 var ext;
     85 
     86 ext = RE_EXTNAME_WINDOWS.exec( 'index.js' )[ 1 ];
     87 // returns '.js'
     88 
     89 ext = RE_EXTNAME_WINDOWS.exec( 'C:\\foo\\bar\\home.html' )[ 1 ];
     90 // returns '.html'
     91 
     92 ext = RE_EXTNAME_WINDOWS.exec( 'foo\\file.pdf' )[ 1 ];
     93 // returns '.pdf'
     94 
     95 ext = RE_EXTNAME_WINDOWS.exec( 'beep\\boop.' )[ 1 ];
     96 // returns '.'
     97 
     98 ext = RE_EXTNAME_WINDOWS.exec( '' )[ 1 ];
     99 // returns ''
    100 
    101 ext = RE_EXTNAME_WINDOWS.exec( '\\foo\\bar\\file' )[ 1 ];
    102 // returns ''
    103 
    104 ext = RE_EXTNAME_WINDOWS.exec( 'C:\\foo\\bar\\.gitignore' )[ 1 ];
    105 // returns ''
    106 ```
    107 
    108 </section>
    109 
    110 <!-- /.examples -->
    111 
    112 <section class="links">
    113 
    114 [regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
    115 
    116 </section>
    117 
    118 <!-- /.links -->