Re: ereg_replace
| From: | Dash McElroy | Date: | Wed, 12 Feb 2003 19:50:31 +0000 |
| Subject: | Re: ereg_replace | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-18499@lists.php.net to get a copy of this message | ||
I would just cut the text off via explode at the ? mark.
i.e.:
$shorturl = explode("?", $str, 1); //may or may not work...
then echo $shorturl[0];
-Dash
Sturgeon's Law:
90% of everything is crud.
On Wed, 12 Feb 2003, Bobo Wieland wrote:
> I'm using ereg_replace to find urls as said in the manual. I've changed it a
> tiny litte bit to remove the http:// part when displaying the
> link, like
> this:
>
> $str =
> ereg_replace("([[:alpha:]]+://)([^<>[:space:]]+[[:alnum:]/])","<a
> href='\\0' class='red' target='_blank'
> onfocus='this.blur()'>\\2</a>",
> $str);
>
> I'm trying to get the grips of regular expressions but I can't figure this
> one out; If the url includes a query-string I don't want it to be shown. So
> the url
> http://www.elstudion.com/index.php?foo=bar should be replaced
> with:
>
> <a
>
> href='http://www.elstudion.com/index.php?foo=bar'>www.elstudion.com/index.ph
> p</a>
>
> How do I do this?
>
>
> Thanks!
>
>
> .bobo
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>