Concrete may have
Ships were lost du
Joe's Bar and Gril
Ships were lost du
But first, you and
Chris! I told you
Release me. Now. O
Concrete may have
Ships were lost du
Joe's Bar and Gril

Chapter 1. Once
Chris! I told you
But first, you and
Tiffany, you reall
Joe's Bar and Gril
Release me. Now. O
Quietly, Quiggly s
Quitetly, Quiggly
Chapter 1. Our st
That turned dark q
Stop dancing like that. it looks like A

J I'm trying to do this using regex that will add a line break after every occurrence of
. So far, I tried $new_str = preg_replace('//', '
\n', $str); but that is not working. A: The problem is that your regex only allows one or zero space before BR. In the second match, the group is empty. Try this: $new_str = preg_replace('/\)/', '\n', $str); This regex will not find anything if the match is "not" inside of a tag, so I also replaced it with \n. A: i do not think there is a way to do it with simple regex, because you are trying to detect
inside tags, which is not valid html. $str = 'I am some random text and a
.
and
again!'; $newStr = preg_replace('/
/', '
', $str); echo $newStr; // I am some random text and a
.
and
again! A: preg_replace('/
/','
',$string); That should do it for you. As @hwnd suggested, I've added in the ? to make it optional. \/\> seems the right way to indicate a BR in a tag, but I wanted to make sure to cover more cases (perhaps in the future you'll want to leave off the space and have something else, like: This
is
some text.
For now, here's a full set of cases to cover: preg_replace('/]/','
',$string); preg_replace('//','
',$string); preg_replace('/]/','
',$string); preg_replace('/
(.*)/','
',$string); preg_replace('/])?[ ]?.*?\/?\>/i','$1',$string); And an example of the regex working on the html:
this is text before







































































































































































































































































































































































































































































































<