Solved

split "lines" into array

Posted on 2004-08-17
4
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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. …
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

724 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