| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2006-07-20 15:17 UTC] mike@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 00:00:01 2025 UTC | 
Description: ------------ It's not possible to use the $n style backreference in the pattern of the PCRE functions. A pattern like this: /\[(u|b|i|s)\](.*)\[\/$1\]/si Should match [b]bold[/b]. However, it does not. This pattern though: /\[(u|b|i|s)\](.*)\[\/\\1\]/si _Will_ match [b]bold[/b]. Reproduce code: --------------- <?php function parseUBB($sString) { // Bold, underline, italic and strike tags $sString = preg_replace("/\[(u|b|i|s)\](.*)\[\/$1\]/si", "<$1>$2</$1>", $sString); return ($sString); } echo parseUBB("[b]testb[/b], [u]testu[/u], [i]testi[/i]"); ?> Expected result: ---------------- <b>testb</b>, <u>testu</u>, <i>testi</i> Actual result: -------------- [b]test[/b], [u]testu[/u], [i]testi[/i]