split with javascript

Posted by Sourabh on Stack Overflow See other posts from Stack Overflow or by Sourabh
Published on 2010-05-12T06:50:45Z Indexed on 2010/05/12 6:54 UTC
Read the original article Hit count: 215

Filed under:
|

Hi

below is something I am trying to do with JavaScript.

If I have string like

str = "how are you? hope you are doing good" ;

now I want to split it with ? but I dont want to lose the "?". Instead I want to break the string just after the question mark such a way that question mark is with the first segment that we have

after splitting str what should I get is

["how are you?","hope you are doing good"]

I am not sure if it can be done with Javascript split() function ,please help.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex