# [EMAIL PROTECTED] / 2006-11-13 01:35:44 +0200:
> On 13/11/06, Chris <[EMAIL PROTECTED]> wrote:
> >
> ><?php
> >function makeLink($matches) {
> > $returnString="<b>" . $matches[1] . "</b>";
> > return $returnString;
> >}
> >
> >$articleText="This is a very [long] string.";
> >$articleText=preg_replace_callback('/\[([a-z]+)\]/i' , "makeLink",
> >$articleText);
> >print $articleText . "\n";
> >?>
> >
> >
> >The callback takes whatever the regular expressions returns (alpha
> >characters between [ and ]) and runs it through function "makeLink".
> >
> >Not sure how that will go with multiple []'s etc in the same string but
> >it should get you started.
> >
>
> I didn't know that I had to call the function like that- I don't
> remember ever seeing it called that way.
It's done this way in all the examples on
http://cz.php.net/manual/en/function.preg-replace-callback.php
What documentation did you read?
> Also, I must google the meaning of the (~+) in the regex.
No need to google:
http://cz.php.net/manual/en/reference.pcre.pattern.syntax.php
Skip the Differences From Perl section.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php