Click here to Skip to main content
15,566,994 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to remove " "
"'A', 'B', 'C'"

and create string as

'A', 'B', 'C'
Posted
Comments
F-ES Sitecore 9-Dec-15 4:28am    
Google "remove text javascript" or "replace quotes javascript"
Member 10902837 9-Dec-15 5:18am    
my string is "'A', 'B', 'C'"
but i need ['A', 'B', 'C']
F-ES Sitecore 9-Dec-15 5:38am    
I'd probably take the inner substring (omitting the first and last chars) and then add the brackets.
Member 10902837 9-Dec-15 6:12am    
can u please give an example
F-ES Sitecore 9-Dec-15 6:17am    
using substring

The first param will be 1 and the second param will be the length of the string - 2. You then use string concatenation to add a "[" to the start and "]" to the end.

1 solution

I have tried with following sample code which is giving expected output. Look closely you might be missing something else.

<p id="demo"></p>

<script>
function myFunction() {
    var arr = ["'A', 'B', 'C'"];
    document.getElementById("demo").innerHTML = arr;
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900