[PHP] Re: reg-ex again
[EMAIL PROTECTED] (John Fishworld) wrote: I'm trying to find files in my array for example =lg_imode.gif and =/db/imodeklein/edgar-IMODE-1-.gif I want to differentiate between the files with slash at the front and ones without so that I can add a server path ! but as usual I' m having problems with the correct regex what about something simple as: $str = /db/skod.gif; if (strpos($str, /) == 0) { echo Slash first; } else { echo Slash not first; } -- Henrik Hansen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: reg-ex again
No the problem is I'm reading a file into an array and then need to change any of the links in the file from relative links to absolute links ! So that my lg_mode.gif gets the full server path in front of it http://www.ltest.com/lg_mode.gif and exactly the same with the other one but of course I don't won't http://www.test.com//folder/name.gif I'm trying to find files in my array for example =lg_imode.gif and =/db/imodeklein/edgar-IMODE-1-.gif I want to differentiate between the files with slash at the front and ones without so that I can add a server path ! but as usual I' m having problems with the correct regex what about something simple as: $str = /db/skod.gif; if (strpos($str, /) == 0) { echo Slash first; } else { echo Slash not first; } -- Henrik Hansen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: reg-ex again
On Monday 29 April 2002 17:10, John Fishworld wrote: No the problem is I'm reading a file into an array and then need to change any of the links in the file from relative links to absolute links ! So that my lg_mode.gif gets the full server path in front of it http://www.ltest.com/lg_mode.gif and exactly the same with the other one but of course I don't won't http://www.test.com//folder/name.gif I'm trying to find files in my array for example =lg_imode.gif and =/db/imodeklein/edgar-IMODE-1-.gif I want to differentiate between the files with slash at the front and ones without so that I can add a server path ! but as usual I' m having problems with the correct regex Not sure if I understand your problem correctly. Define your server path as: http://www.myserver.com/some/path (NB no trailing slash) If the first char of file contains '/' use: $server_path$file otherwise use: $server_path/$file -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Why is the alphabet in that order? Is it because of that song? -- Steven Wright */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: reg-ex again
Sorry don't think I've explained this very clearly ! :-)) Start again People can enter a url with code in, this gets copied to a different server and read as an array ! At this point, the original server path needs to be added to the links in the copied file. The basics of this do actually already work - I just need the regex expression to find any files with name.gif (only allowing letters,numbers and _) and to find files /pics/name.gif - that is same rule but starting with a forward slash And at that point they all get replaced with the server path and written to the file ! On Monday 29 April 2002 17:10, John Fishworld wrote: No the problem is I'm reading a file into an array and then need to change any of the links in the file from relative links to absolute links ! So that my lg_mode.gif gets the full server path in front of it http://www.ltest.com/lg_mode.gif and exactly the same with the other one but of course I don't won't http://www.test.com//folder/name.gif I'm trying to find files in my array for example =lg_imode.gif and =/db/imodeklein/edgar-IMODE-1-.gif I want to differentiate between the files with slash at the front and ones without so that I can add a server path ! but as usual I' m having problems with the correct regex Not sure if I understand your problem correctly. Define your server path as: http://www.myserver.com/some/path (NB no trailing slash) If the first char of file contains '/' use: $server_path$file otherwise use: $server_path/$file -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Why is the alphabet in that order? Is it because of that song? -- Steven Wright */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php