I am not finding solution to add variable inside following RegEx
val.replace(/[^\d.]/gm,'')
Basically I need to change the .
to variable.
Something like
val.replace("/[^\d"+sepaeator+"]"/gm,'')
I am not finding solution to add variable inside following RegEx
val.replace(/[^\d.]/gm,'')
Basically I need to change the .
to variable.
Something like
val.replace("/[^\d"+sepaeator+"]"/gm,'')
Use a RegExp
instance (mdn):
const regex = new RegExp(`[^\d${separator}]`, 'gm');
val.replace(regex, '');