Tautvydas Tautvydas - 2 months ago 5x
Javascript Question

RegExp: find "//" followed by any symbol except space

Title says it all. My intention is to insert a space by replacing the match with

"// "

So far I tried this:

\/\/\b(?! )

But this does not match strings such as


Use a negative look ahead for a space:

\/\/(?! )

Although this answers your question as stated, I suspect you actually don't want to match when // is at the end of a line (which would qualify under your question's definition). If so, use a positive look ahead for a non whitespace char:


Or alternatively, use \B to match a non-word boundary:


which will possibly impress your colleagues more.