Re: Can I use a function within an ereg_replace?

From: Date: Tue, 03 Apr 2001 18:36:26 +0000
Subject: Re: Can I use a function within an ereg_replace?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-46865@lists.php.net to get a copy of this message
> On 4/3/01 11:06 AM, "Dan Wilson" <dan@acucore.com> wrote: > >> Hey all, >> >> I'm trying to mangle email addresses to pass to an email sending form and >> want to use a custom hashing function within an eregi_replace. >> >> Example: >> >> $text = eregi_replace("[my big email regex]", "send.php?addr=" . >> hash_func("\\1@\\2.\\3"), $text); >> >> I can't seem to get this to work... it is just hashing the static text >> within the function, not the replaced values. >> >> Can this just not be done? >> >> -Dan >> And after more carefully reading your code... I think you are going to have to get your matches before the replace, then pass the matches to hash_func, then do the replace. Am I reading that right? Your [big email regex] contains 3 groupings that you want \1,\2,\3 to be, and you want those values passed to hash_func()? ereg([big email regex],$text,$match) // $match[1] = \1 // $match[2] = \2 // etc // // $match[0] is the entire matched string, not the first sub group in the regex // Then $text = eregi_replace("[my big email regex]", "send.php?addr=". hash_func("$match[1]@$match[2].$match[3]"), $text);

« previous php.general (#46865) next »