By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Help on JavaScript replace


New Coder
Hello – I have a string reads like below. I need a JS to strip the comma between the double quotes.

Input String… T06502-000,,10-Jan-23,vicsim,23042,10-Jan-23,"$2,875.99",10-Jan-23,1,NS,”REPAIR, G11-MASTER NUT”,SN# 7987346,FALSE,1,"$1,750.90",EA,1750.9,USD,150

Expected Output..

T06502-000,,10-Jan-23,vicsim,23042,10-Jan-23,$2875.99,10-Jan-23,1,NS,REPAIR G11-MASTER NUT,SN# 7987346,FALSE,1,$1750.90,EA,1750.9,USD,150

Need to strip the comma between the double quote

inside = FALSE
new = ""
FOR i=1 TO LENGTH OF string
  x = c
  IF c == QUOTE
    inside = NOT(inside)
  IF c == COMMA
    IF inside
      x = ""
  CONCATENATE new and x
OP you should know that I had to replace the commas and the double quotes in your string. Also, you have two commas before the date 10-Jan-23, I removed one. Read the comments in the code.
    <p id="demo"></p>
str = 'T06502-000,10-Jan-23,vicsim,23042,10-Jan-23,"$2,875.99",10-Jan-23,1,NS,"REPAIR, G11-MASTER NUT",SN# 7987346,FALSE,1,"$1,750.90",EA,1750.9,USD,150';
arr = str.split('"'); /*This is a double quote inside of two single quotes*/
newArr ="";
for ( i = 0; i < arr.length; i++) {
        arr[i] = arr[i].replace(",", "");
    newArr = newArr.concat(arr[i]);
text = newArr.toString();
document.getElementById("demo").innerHTML = text;

This keeps the comma after the word repair, if it needs to be removed and you can't figure out how to change my code (easy to do) come back and I'll do it for you.
Peace ✌️

New Threads

Buy us a coffee!

Top Bottom