Home  >  Q&A  >  body text

Why does \\1 inherit (.*) instead of replacing it? ? ?

<?php

$string='[b]Write poems for you[/b]

[i]Do impossible things for you[/i]

$pattern=array(

'/\[b\](.*)\[\/b\]/i',

'/\[i\]( .*)\[\/i\]/iU',

);

$replace=array(

'<b>\\1</b> ;<br />',

'<i>\\1</i><br />',

);

$ ubb=preg_replace($pattern,$replace,$string);

echo $ubb;

Why does \\1 inherit (.*) instead of replacing it? ? ?


  2429 days ago1603

reply all(1)I'll reply

  •  

     2018-01-29 16:01:58

    Is it possible that only replacement can contain back references\\nIs this explanation? That means it's fixed?

    reply
    0
  • Cancelreply