troubleshooting Question

Replace white space with comma

Avatar of lulu50
lulu50Flag for United States of America asked on
C#JavaScriptjQueryJSON
5 Comments1 Solution128 ViewsLast Modified:
Hi,

I have a textarea where I want the system to replace all the white spaces with a comma.

my code works if I hit the break between each input but if I have my text without hitting the break between each text
it will not replace the white spaces with a comma.

this is what I have:


           var str = $('#ItemList').val();

            str = $('#ItemList').val().replace(/(?:\r\n|\r|\n)/g, ',');
           
            var partsOfStr = str.split(', ');
       
            $('#ItemList').val(partsOfStr);

 Thank you for your help

Lulu
ASKER CERTIFIED SOLUTION
gr8gonzo
Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros