How could I replace comma inside double quote using nodejs or nodejs moudle like fs ?
input: 48,"LHT0019","TEST COUNT (HB,TW,DC,PL)"
output: 48,"LHT0019","TEST COUNT (HB TW DC PL)"
How could I replace comma inside double quote using nodejs or nodejs moudle like fs ?
input: 48,"LHT0019","TEST COUNT (HB,TW,DC,PL)"
output: 48,"LHT0019","TEST COUNT (HB TW DC PL)"
Something like this?
'48,"LHT0019","TEST COUNT (HB,TW,DC,PL)"' // Your string
.replace(
/(["'])(?:(?=(\\?))\2.)*?\1/g, // REGEX to find text in quotes
function(match, capture) { // Pass result to a function to modify further
return match.replace(/\,/g, ' '); // REGEX to remove all ","
}
);
Uses REGEX to find and then modify the strings.
With a little help from RegEx: Grabbing values between quotation marks
You ca use str.replace
as follows
var str = "TEST COUNT (HB,TW,DC,PL)";
console.log("rrrr", str.replace(/,/g," "));
OUTPUT:
TEST COUNT (HB TW DC PL)