Solved

split "lines" into array

Posted on 2004-08-17
4
247 Views
Last Modified: 2012-05-05
I want to split HTML text divisions into an array for further parsing.

The HTML is rather simple, only <br> and <p> separating text.
How can split the text into an array as if I were using:

lines = text.split("\n");

but with <br> & <p> instead of "\n"?

thanks.
0
Comment
Question by:Esopo
  • 2
4 Comments
 
LVL 5

Expert Comment

by:darksinclair
ID: 11825772
Try this :

lines = text.split(chr(13));

chr(13) is the carriage return.  I think that's what your looking for.

Cheers.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
ID: 11825902
Like this:

lines = text.split(/(<br>|<p>)/i);

0
 
LVL 14

Author Comment

by:Esopo
ID: 11826035
Beautiful!

Thank you.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11826054
You are welcome.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question