If you are trying to define a regex in a helper for a lightning component for example and you try to do something like this simple regex to match a single
var myRegex = /\//;
var myRegex = new RegExp(/\//gi);
The parser will let you save, but the generated source js file that will be served to load your lightning component will look like this:
var myRegex = /\
var myRegex = new RegExp(/\
This will make the whole page crash in a lightning community for example with the following exception
leftover configs Action failed: aura://ComponentController/ACTION$getComponent
My guess is that this is because all comments are removed from the files served as js source and it is picking up the last
// of the regex as the start of comments and so it is removing the rest of the line. By the way if you have a component with this in your community it will not load anymore and it will be impossible then to remove that component, even in the builder.
This was very frustrating to figure out also because of the lack of proper error message and the crashing community. Hoping this might help someone else figure out their problem.
(I have not tested this in LEX)