javascript – Regex to fix malformed vector

I have an API that is returning the following, malformed string:

M0 0L1.33333 0L1.33333 4L4.44089e-16 4L0 0Z

It should look like this:

M 0 0 L 1.33333 0 L 1.33333 4 L 4.44089e-16 4 L 0 0 Z

How could I write a regex that would select any letter that has a number next to it, preceding or following?

Here are the strings again, next to each other:

M0 0L1.33333 0L1.33333 4L4.44089e-16 4L0 0Z <-incorrect

M 0 0 L 1.33333 0 L 1.33333 4 L 4.44089e-16 4 L 0 0 Z <-correct

Thanks!

A little background: this is a vector returned by the Figma API and I don’t know why it’s formatted like that.

Source link