Created
July 5, 2018 06:07
-
-
Save helinjiang/640b365ed377bef99b8a9c41f7337257 to your computer and use it in GitHub Desktop.
remove path pre
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
let reg1 = /^\.([^[\\||\/])*[\\||\/]/gi; | |
let reg2 = /^\.([^[\\||\/])*[\\||\/]/gi; | |
let windowsPath = '..\\e2e_test\\page_rule\\cases\\basic-ui-check.js'; | |
console.log(windowsPath.match(reg1)); // [ '..\\' ] | |
console.log(windowsPath.replace(reg2, '')); // e2e_test\page_rule\cases\basic-ui-check.js | |
console.log('\n=====\n'); | |
let macPath = '../e2e_test/page_rule/cases/basic-ui-check.js'; | |
console.log(macPath.match(reg1)); // [ '../' ] | |
console.log(macPath.replace(reg2, '')); // e2e_test/page_rule/cases/basic-ui-check.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment