I am the front-end layman, JS I use less. Today, accidentally found that JS comes with the replace "incredibly" replaced only 1, and many other languages are replaced by all. You might say, cut, I've known. Master please take a detour. You might say that you can solve this problem with JS's regular. Yes, that's right, but I am has a "don't use regular" hobby. So come up with a way, since JS you only help me do once, I will loop let you do many times, the code is written by others:
function ReplaceAll (str, sptr, SPTR1) {while (Str.indexof (sptr) >= 0) { str = str.replace (sptr, SPTR1); } return str;}
Glad to find a solution. But the post code says "I don't feel like it", and here's an example: ReplaceAll (A, ' B ', ' BC ') will die. I'm sweating! I know it's going to be a dead loop without running. Disappointed. Later, I thought of a way:
function ReplaceAll (str, sptr, sptr1) { var ps = str.split (sptr); var s2 = ps.join (SPTR1); return S2;}
Put it up for your master to see if this approach is flawed.
I'd like to write a memo.
The solution to the replace problem of JavaScript (JS)