-2

I need to isolate and replace double quote assigned to character and not the number.

For example: I bought 4" plywood from a" store

basically I want to fine and replace " that is assigned to a and leave the one that assigned to digit intact, so the outcome should be I bought 4" plywood from a store

Thank you

  • 3
    What have you tried so far? SO is not a free coding service. See [How to Ask](https://stackoverflow.com/help/how-to-ask) and [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Reyno Apr 28 '21 at 06:56
  • See also [Reference - What does this regex mean?](https://stackoverflow.com/q/22937618/4642212) and use regex debuggers like [RegEx101](https://regex101.com/). Particularly, look into lookarounds (lookaheads or lookbehinds) and try something yourself. – Sebastian Simon Apr 28 '21 at 07:00
  • 1
    For what programming language is your question, javascript or ABAP? Choose only one of the two tags please. – Sandra Rossi Apr 28 '21 at 07:23

1 Answers1

1

Try to match a char + " and to replace it in string (removing "):

let str = "I bought 4\" plywood from a\" store";
let match = str.match(/([A-Za-z]")/i);
let res = str.replace(/([A-Za-z]")/i, match[0].replace("\"", ""));
console.log(res);
Giovanni Esposito
  • 5,165
  • 1
  • 5
  • 23