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: 349
I want to change
<lang class='brush:xhtml'>test</lang>
to
<pre class='brush:xhtml'>test</pre>
my code like that.
<?php
$content="<lang class='brush:xhtml'>test</lang>";
$pattern=array();
$replace=array();
$pattern[0]="/<lang class=([A-Za-z='\":])* </";
$replace[0]="<pre $1>";
$pattern[1]="/<lang>/";
$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