Alex Rivera | Logout

split string by hyphen in javascript

Asked 2011-02-11T07:27:25.060
19

I want to split following string into two parts using split function of javascript

original string is 'Average Sized' - 'Mega Church!' (with single quotes)

please mark that there is a single quote inside the string

and i want to split it by hyphen symbol so the result would be

[0] Average Sized 
[1] Mega Church!
Edit
Report

1 Answer

29
var str = "Average Sized - Mega Church!";
var arr = str.split("-");
answered 2011-02-11T07:31:45.450

Your Answer