This doesn’t work and will give $1$
(expected: $1234$
):
"$ 1234 $".replace(/$ *(.+?) *$/, "$$1$")
On the other hand,
"$ 1234 $".replace(/$ *(.+?) *$/, "$ $1$")
returns $ 1234$
correctly.
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
This doesn’t work and will give $1$
(expected: $1234$
):
"$ 1234 $".replace(/$ *(.+?) *$/, "$$1$")
On the other hand,
"$ 1234 $".replace(/$ *(.+?) *$/, "$ $1$")
returns $ 1234$
correctly.