Regex to match a space character preceded by a space character

javascript, regex

Solution

Because of the lack of lookbehinds, the best you can do is find the overall match using this, and then just use capture group `1`:

/(?: )( +)/g

Or, in whatever code uses the match information, just assume that the first character is a space, and use this regex:

/ +/g

Problem

I'd like to write a regex to match the marked characters marked with a `'^'` in the following string ``` this is a string ^ ^^^ ^^^^ ``` But I'm confused about a) how to match a character based on the character preceding it, and b) how to match a space that is really just a space and not a tab (\t) or a new line (\n) char I need this to work in javascript, if that makes any difference. Any thoughts?

Original source