I've searched all around the web for a response to this question,
Why do my .replace only replace chars that doesnt have any other char behind
My code is :
const fixedstring = string.replace('&', '^&')
When i enter : ¬epad.exe& has a string, it give me the output ^¬epad.exe& instead of ^¬epad.exe^&
Can someone help me ? (i've tried the /g)
Thanks for the guy that will help me or just read my post, thanks !
You can't use the global flag /g unless you are using regex to find the characters to replace. You are currently using a string to find, which will only match the first instance.
Instead, use the regex:
.replace(/&/g, "^&")
Here is a working example.
const stringToReplace = "¬epad.exe&"
const replaced = stringToReplace.replace(/&/g, '^&')
console.log(replaced)