RegEx replace not working in PHP -


i've written regular expression first 2 paragraphs database clob stores content in html formatting.

i've checked these online regex builder/checkers here , here , both seem doing want them (i've altered regex since these checkers handle new line formatting found after.

however when go use in php doesn't seem want group i'm after, , instead matches everything.

here preg_replace line:

$description = preg_replace('/(^.*?)((<p[^>]*>.*?<\/p>\s*){2})(.*)/', "$2", $description); 

and here testing content in format of content getting

<p>      paragraph 1</p>  <p>      paragraph 2</p>  <p>      paragraph 3</p> 

i've had @ this post didn't help.

any ideas?

edit

as pointed out in 1 of comments cannot regex html in php (don't know why, i'm not bothered that).

now i'm opening option getting in pl/sql well.

select      dbms_lob.substr(description, 32000, 1) /* how make regular expression? */     blog_posts 

you take @ php simple dom parser. going manual, so:

$html = str_get_html('your html string'); foreach($html->find('p') $element)   //this should paragraph elements in string.        echo $element->plaintext. '<br>'; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -