JavaScript Regular Expression help How do I wrap a set of pa

JavaScript: Regular Expression help:

How do I wrap a set of parens around each character in a string?

For example if the given string is \"papa\" the result should be \"(p)(a)(p)(a)\"

Solution

str.split(\"\"); to split string into chars and then embrace each char with paranthsis and join to make string again

var s= \"papa\";

var a=s.split(\'\');
var s2=\"\";
for(i=0;i<a.length;i++)
s2=s2+\"(\"+a[i]+\")\";
alert(s2);

JavaScript: Regular Expression help: How do I wrap a set of parens around each character in a string? For example if the given string is \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site