Q: How to write big regexp in multiple lines javascript? I have a long long regexp, like this (it's example):
/111|112|113|...|998|999/

How can I make it multiline to edit it with ease? Something like that:
/
111
|112
|113
...
|998
|999
/


A: You can create regexp using constructor:
new RegExp('/'
+ '111'
+ '|112'
+ '|113'
+ '...'
+ '|998'
+ '|999'
+ '/');

From ES6 you can also use backticks to write multiline strings:
new RegExp(`/
111
|112
|113
...
|998
|999
/`);


A: var str = "/111|112|113|...|998|999/";
var splitArr = str.split("|");

function divide(){
   var s= "";       
   for(var i=0;i<splitArr.length;i++){
    var item = splitArr[i] + "\n";
    s +=  item;
   }
    return s
}

console.log(divide());

