Q:

JS Regex Positive Lookbehind

I want to split a string by space. But without removing it and it should be added to the previous string and not to the next.
As you see in the result the space got added to the next word.
Here is my regex101.
Regex:
/(?=\040)/g
Result:
"Lorem| ipsum| dolor| si| amet."
What I need
"Lorem |ipsum |dolor |si |amet."

A:

Try this regex:
\b(?=\w)

OR
\b(?=[^\040.])

Click for Demo
Explanation:

\b - Word Boundary
(?=\w) - Positive lookahead ensuring that a word character follows \b

OR

(?=[^\040.]) - Positive lookahead ensuring that \b is followed by any character but  or .

