Advertisement
Guest User

Regex Config

a guest
Feb 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const RegExpBracketOpen = new RegExp(/\[/g);
  2.  
  3. const RegExpBracketClose = new RegExp(/\]/g);
  4.  
  5. const RegExpKoma = new RegExp(/\,/g);
  6.  
  7. let config = `a = ["foo","bar","baz","qux"]`;
  8.  
  9. config = config.replace(RegExpBracketOpen, '[\n');
  10.  
  11. config = config.replace(RegExpBracketClose, '\n]');
  12.  
  13. config = config.replace(RegExpKoma, ',\n');
  14.  
  15. console.log(config);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement