?
Solved

split "lines" into array

Posted on 2004-08-17
4
Medium Priority
?
252 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 1200 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

800 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