PHP Regular Expression

Posted by saturngod on Stack Overflow See other posts from Stack Overflow or by saturngod
Published on 2010-06-12T09:07:40Z Indexed on 2010/06/12 9:12 UTC
Read the original article Hit count: 346

Filed under:
|

I want to change

<lang class='brush:xhtml'>test</lang>

to

<pre class='brush:xhtml'>test</pre>

my code like that.

<?php
$content="&lt;lang class='brush:xhtml'&gt;test&lt;/lang&gt;";
$pattern=array();
$replace=array();
$pattern[0]="/&lt;lang class=([A-Za-z='\":])* &lt;/";
$replace[0]="<pre $1>";

$pattern[1]="/&lt;lang&gt;/";
$replace[1]="</pre>";
echo preg_replace($pattern, $replace,$content);
?>

but it's not working. How to change my code or something wrong in my code ?

© Stack Overflow or respective owner

Related posts about php

Related posts about regex