Thread: Regex Problem
View Single Post
Old 05-09-2011, 09:42 AM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,134
Karma: 60406498
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by huebi View Post
Hi,

how can i change


Code:
<div>
  sentence1<br />
  sentence2<br />
  sentence3<br />
  sentence4<br />
</div>
into

Code:
<p>sentence1</p>
<p>sentence2</p>
<p>sentence3</p>
<p>sentence4</p>
The Problem is there several amounts of sentences, sometimes 2, sometimes 3, sometimes more. Is there a way to do that with a regex? There are more then 500 div-sections, so doing that manually is a pain. A workaround might be doing it with 2, then 3, then 4 and so speratly.

thx in advance
I would do the Div first
<div>(.+)<br />\s+</div>

<p>\1</p>

now

replace the:

<br />

with
</p> <p>

Tidy will clean the code view after switching to BV
choosing the best order, leaves the least touch-up

Last edited by theducks; 05-09-2011 at 09:44 AM. Reason: revised
theducks is offline   Reply With Quote