Re: Parsing HTML href-Attribute
| From: | Edmund Hertle | Date: | Fri, 16 Jan 2009 21:32:52 +0000 |
| Subject: | Re: Parsing HTML href-Attribute | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286530@lists.php.net to get a copy of this message | ||
>
> * http://www.google.com/search?q=php ... absolute path (yes,
> it's a URL,
> but treat it as absolute)
> * https://www.example.com/index.php ... absolute path (yes,
> it's a URL,
> but to the local server)
> * /index.php ... absolute path (no protocol given, true absolute path)
> * index.php ... relative path (relative to current directory on current
> server)
> * somefolder/index.php ... relative path (same reason)
>
> That is indeed a nifty use of look-ahead, though. That will work for any
> anchor tag that doesn't reference the server (or any other server) with a
> protocol spec preceding it. However, if you want to run it through an entire
> list of anchor tags with any spec (http://, https://, udp://,
> ftp://,
> aim://, rss://, etc.)--or lack of spec--and only mess with those that don't
> have a spec and don't use absolute paths, it needs to get a bit more
> complex. You've convinced me, however, that it can be done entirely with one
> regex pattern.
>
> // Todd
Hey!
Wow, I think that was exactly what I was looking for... thank all of you...
although I've not tested it, will do that tomorrow, but sounds very nice
But Todd just confused me quite a bit with the statement: Is /index.php a
case where the RegEx will fail?
To add some background: It is about dynamiclly creating pdf files out of
html source code and then the links should also work in the pdf file. So
other protocolls then http:// shouldn't be a problem
-eddy