milesperhour1086 Posted May 8, 2006 Share Posted May 8, 2006 If I have an output buffer callback function as follows:[code]function callback($buffer) { global $offset; $patternUW = "@u.washington.edu$"; if(ereg("<a href=\"mailto:(.*)\".*>.*</a>",$buffer)) { $buffer = eregi_replace("<a href=\"mailto:(.*)\".*>(.*)</a>","<a href=\"".$offset."/_inc/mail.php?email=\\1\">\\2</a>",$buffer); $buffer = callback($buffer); break; } return $buffer; }[/code]and I want to do the following:[ol type=\'1\'][*]Determine whether @u.washington.edu is the domain its from[*]do a different eregi_replace function if it isn't vs. if it is[*]but don't want a never-ending recursive loop[/ol]how would I do that? I tried a simple if elseif else statement but it turned out to be neverending. Any ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/9341-simple-regex-help/ Share on other sites More sharing options...
sanfly Posted May 8, 2006 Share Posted May 8, 2006 Can you explain the function you have a little more? Is it unfinished? what exactly is it trying to do? what is $offset? Why do you never use the $patternUW variable after you define it?Why do you have the break where you do? as far as i can tell, the break will never be called because the function is re-executed before it ever gets to it. Quote Link to comment https://forums.phpfreaks.com/topic/9341-simple-regex-help/#findComment-34453 Share on other sites More sharing options...
milesperhour1086 Posted May 9, 2006 Author Share Posted May 9, 2006 Basically, what's happening is I created an output buffer that will check all hyperlinks and if it finds a mailto: link, it will replace it with mail.php?email=.... . That function, callback($buffer) is used in the output buffer process as follows:[code]<?ob_start('callback');function callback($buffer) { global $offset; if(ereg("<a href=\"mailto:(.*)\".*>.*</a>",$buffer)) { $buffer = eregi_replace("<a href=\"mailto:(.*)\".*>(.*)</a>","<a href=\"".$offset."/_inc/mail.php?email=\\1\">\\2</a>",$buffer); $buffer = callback($buffer); } return $buffer; }?>//SOME HTML GOES HERE<?ob_end_flush();?>[/code]What I want to do is add an additional ereg() function in there to check if the link is directed to an @u.washington.edu e-mail address or if the mailto: link is to some e-mail address in general. I only want to make changes to the @u.washington.edu e-mail addresses due to requirements by the department I'm working for. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/9341-simple-regex-help/#findComment-34638 Share on other sites More sharing options...
akitchin Posted May 10, 2006 Share Posted May 10, 2006 this may be an archaic way of doing things, but i would suggest simply matching once with a pattern that picks up ONLY U of Washington addies, and once more recognizing the general pattern. Quote Link to comment https://forums.phpfreaks.com/topic/9341-simple-regex-help/#findComment-34801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.