Reputation: 27
I'm working on small project and stuck with bbcode pattern regex convert into html pattern regex.
Currently code working using [pre] [/pre]
BBcode; I want to code work HTML regex:
$pattern = '#\[pre\](.*?)\[\/pre\]#si';
$pattern = '#\[.?pre\]#si';
I try to convert it as below, but it's not working (Didn't get expect results):
$pattern = '#\<pre\>(.*?)\<\/pre\>#si';
$pattern = '#\<.?pre\>#si';
Upvotes: 2
Views: 262
Reputation: 53535
I'm not sure how you're using the regex but the following works for me:
<?php
$text = "<pre>regex use check inside pre tag conetent</pre>";
$found = preg_match( '#\<pre\>(.*?)\<\/pre\>#si', $text, $matches);
echo $matches[1]; // prints: "regex use check inside pre tag conetent"
?>
Upvotes: 2