php - Extracting text after before and after a | using preg_replace -
in efforts build stackoverflows linking system trying this;
$raw = '[[path.html|link description]]'; $str = preg_replace('#\[(\?)|(\?)]#', '<a href="$1">$2</a>', $raw); echo $str; //$str should not <a href="path.html">link description</a>
this should have worked, keep getting same text output. idea put part before |
href
, 1 after |
link description. in end, have fail.
i took woking example, i'm stuck after adding |
part.
the problem on regex hadn't escaped |
having or
expression.
you can use regex:
\[\[(.*?)\|(.*?)\]\]
Comments
Post a Comment