I have to escape two special characters " and , in the string with the following rules.
Example:-
- Mercu"ry should be converted into "Mercu""ry"
- Mercu,ry should be converted into "Mercu,ry"
- Mer"cu,ry should be converted into "Mer""cu,ry"
Rules:-
- Meaning comma or double quote should be escaped with double quote.
- Comma will escaped by wrapping the whole word in double quotes.
- If Double quote is found, then it double quote should be added at its position. Also the whole word should be wrapped inside the double quotes.
Please suggest the regex pattern in javascript.
Mercu""ry
would becomeMercu""""ry
."Mercu""""ry"
?