search and replace : how does [url=http://somewhere] work?
Posted: Mon Apr 05, 2004 1:43 am
search and replace question
or
how does code behind the [ url=http://somewhere] thing on this site work?
i have a content management system,
which uses templates with tags to mark where the page content should be inserted.
the tags look like this:
so i might have a text file template that goes
my code comes along and replaces the tag with the appropriate text
and if there are any tags left over i clean them up with
and that works just fine, but i would like to add the option of adding parameters inside the tags:
i have seen something on this message board that i pretty much does this
when i post to this message board there is a feature
that allows me to make a link by going [ url=http://somewhere]somewhere[/url]
i imagine there a gazillion ways to find the [ url] tags in a string and extract the information after the (optional) = sign,
but i was wondering if anyone has an opinion on the best way to do it.
how does this message board do it?
cheers
thanks for you help,
mat
or
how does code behind the [ url=http://somewhere] thing on this site work?
i have a content management system,
which uses templates with tags to mark where the page content should be inserted.
the tags look like this:
Code: Select all
{:tag:}so i might have a text file template that goes
Code: Select all
html to set up layout etc,{:menu:}...more layout..{:text:}Code: Select all
<?php
// tags with the format {:tagName:} are replaced with: $text
$template = str_replace("{:".$tagName.":}", $text, $template);
?>Code: Select all
<?php
//clean unused tags
$template = preg_replace("/{:.*?:}/", "",$template);
?>Code: Select all
{:tag optionalInformation:}when i post to this message board there is a feature
that allows me to make a link by going [ url=http://somewhere]somewhere[/url]
i imagine there a gazillion ways to find the [ url] tags in a string and extract the information after the (optional) = sign,
but i was wondering if anyone has an opinion on the best way to do it.
how does this message board do it?
cheers
thanks for you help,
mat