0
I have the following code:
var string = "Este aqui é o valor do cliente 000.000.00 01";
var str_subs = "129.000.000 02";
string = string.replace(/\d\d\d\.\d\d\d\.\d\d \d\d/g, str_subs);
alert("Valor Original: " & ??????); -> No caso aqui eu deveria mostrar 000.000.00 01
alert("Valor Novo: " & str_subs);
I need to show the ORIGINAL Value that replace found before changing, how should I proceed?
Why overwrite the variable value? can’t give different names to the original version and the changed one? And by the way the javascript concatenation character is the
+
, must correct here:alert("Valor Novo: " & str_subs);
– Sergio
@Sergio, corrected thanks. I need to get the value he found inside the string, you know ? I mean, the original value.
– user7605
And why not do
var novaString= string.replace(/\d\ ....etc
and thus maintain the variablestring
with the original value?– Sergio