Javascript Replace with Regex
I want to replace the beginning with @
by Âș
with 0
below is my line
I try to only work for 2 pairs, but doesn't work for 3 pairs, etc.
Example 01:
Input data
@ 8 ~ CÂș + @ 9 ~ CÂș
Output
0 + 0
Example 02:
Input data
@ 11 ~ CÂș + @ 12 ~ P1Âș - @ 13 ~ FÂș
Output
0 + 0 + 0
Below is my code
var tempRes = "@11~CÂș + @12~P1Âș - @13~FÂș";
tempRes = tempRes.replace(/@[0-9]~[A-Z]Âș/i,parseFloat(0));
+3
source to share
3 answers