Jump to content


Photo

Functions in regex


  • Please log in to reply
2 replies to this topic

#1 GeorgeMoney

GeorgeMoney
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 23 September 2006 - 07:47 PM

Is it possible to use a function in the regex itself? this doesnt work:

$datr = preg_replace("/\[SC\](.*)\[\/SC\]/i", '<a name="'.myurlen("$1").'"></a>', $datr);

--GeorgeMoney

#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 24 September 2006 - 09:09 AM

preg_replace_callback

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 24 September 2006 - 05:28 PM

Or use the e pattern modifier:
$datr = preg_replace("/\[SC\](.*)\[\/SC\]/ie", "'<a name=\"' . myurlen('$1') . '\"></a>'", $datr);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users