Solved

split "lines" into array

Posted on 2004-08-17
4
246 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now