Solved

split "lines" into array

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

707 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

14 Experts available now in Live!

Get 1:1 Help Now