Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
-
trobale
- Forum Newbie
- Posts: 24
- Joined: Mon Apr 23, 2007 11:42 am
Post
by trobale »
What preg_replace syntax should I use when I want to format a text paragraph (that is delimetered by \n\n) to html paragraph <p></p>.
eg I have the following text:
some text
some more text
to html:
<p>some text</p>
<p>some more text</p>
Thanks
-
dustrg
- Forum Newbie
- Posts: 7
- Joined: Sat Aug 11, 2007 2:02 pm
Post
by dustrg »
Could you just /g globally replace all "\n\n" with "</p>\n\n<p>" and enclose the resulting string in a "<p>" and "</p>"?
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
There's no /g modifier in PHP's PCRE. That is controlled via secondary parameters.
-
trobale
- Forum Newbie
- Posts: 24
- Joined: Mon Apr 23, 2007 11:42 am
Post
by trobale »
What a fool I am!
Thank You