repl.txt (1907B)
1 2 {{alias}}( [platform] ) 3 Regular expression to split a filename. 4 5 The regular expression is platform-dependent. If the current process is 6 running on Windows, the regular expression is `*.REGEXP_WIN32`; otherwise, 7 `*.REGEXP_POSIX`. 8 9 Parameters 10 ---------- 11 platform: string (optional) 12 Path platform (either `posix` or `win32`). 13 14 Returns 15 ------- 16 re: RegExp 17 Regular expression. 18 19 Examples 20 -------- 21 > var RE = {{alias}}() 22 <RegExp> 23 > var RE_POSIX = {{alias}}( 'posix' ); 24 > var parts = RE_POSIX.exec( '/foo/bar/index.js' ).slice() 25 <Array> 26 > var RE_WIN32 = {{alias}}( 'win32' ); 27 > parts = RE.exec( 'C:\\foo\\bar\\index.js' ).slice() 28 <Array> 29 > var str = RE.toString(); 30 > var bool = ( str === RE_POSIX.toString() || str === RE_WIN32.toString() ) 31 true 32 33 34 {{alias}}.REGEXP 35 Regular expression to split a filename. 36 37 Examples 38 -------- 39 > var RE = {{alias}}.REGEXP 40 <RegExp> 41 42 43 {{alias}}.REGEXP_POSIX 44 Regular expression to split a POSIX filename. 45 46 When executed, the regular expression splits a POSIX filename into the 47 following parts: 48 49 - input value 50 - root 51 - dirname 52 - basename 53 - extname 54 55 Examples 56 -------- 57 > var f = '/foo/bar/index.js'; 58 > var parts = {{alias}}.REGEXP_POSIX.exec( f ).slice() 59 [ '/foo/bar/index.js', '/', 'foo/bar/', 'index.js', '.js' ] 60 61 62 {{alias}}.REGEXP_WIN32 63 Regular expression to split a Windows filename. 64 65 When executed, the regular expression splits a Windows filename into the 66 following parts: 67 68 - input value 69 - device 70 - slash 71 - dirname 72 - basename 73 - extname 74 75 Examples 76 -------- 77 > var f = 'C:\\foo\\bar\\index.js'; 78 > var parts = {{alias}}.REGEXP_WIN32.exec( f ).slice() 79 [ 'C:\\foo\\bar\\index.js', 'C:', '\\', 'foo\\bar\\', 'index.js', '.js' ] 80 81 See Also 82 -------- 83