Alex Rivera | Logout

How to split words using javascript

Asked 2011-10-05T11:44:51.423
13

This might be a simple question but, how do i split words... for example

a = "even, test"

I have used .split to seperate the text with space.

so the result came is like

a = "even,"
b = "test"

But, how do I remove the 'comma' here?

But in some conditions it might get "even test" and in some conditions i might get "even, test". All are dynamic, so how do i check it for both?

Thanks

Edit
Report

1 Answer

1

Just use this code:

var a = "even, test";
var words = a.split(", ");
answered 2011-10-05T11:49:47.243

Your Answer