From: "loren wolsiffer" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: RE: [wdvltalk] Regex help
Date: Wed, 15 Feb 2006 12:56:42 -0800
I am working with an editor that makes two different link structures
depending on the browser used to insert the images.
$MyFile = 'http://localhost/m-ysite/images/image.jpg';
$MyFile =
'http://localhost/m-ysite/editor/plugins/../../../images/image.jpg';
I am really looking for a relative path to the image and want to remove
everything before "images".
I am trying to get this expression(s) to work and it is showing a match.
I just cannot get it to return or replace the targeted words.
if (eregi("http( |[a-z0-9:/.-])*images",$MyFile))
{
$MyFile2 = (eregi("http( |[a-z0-9:/.-])*images",$MyFile));
$pattern = (eregi("http( |[a-z0-9:/.-])*images",$MyFile));
$replacement = '';
$MyFile3 = eregi_replace($pattern, $replacement, $MyFile);
echo"<br>$MyFile"; // retuns the string
echo"<br>$MyFile2"; // retuns the number "1" ??
echo"<br>$MyFile3<br>"; // retuns the whole string again
}
I know to escape some chars but also cannot figure out how to add _ to the
regex
If there is an _ in the url it does not match and no matter what I do I
cannot work it in.
If someone can help get the trimmed string into a variable I can work with
it.
Hi all.
I made a change to the regex and it does exactly what I want as far as the
_ goes.
(eregi("http.+images",$MyFile))
I am still stuck with how to echo the end result
either images/image.jpg or image.jpg
somehow it seems so basic but I am just not getting it
thank you
Loren
I found the solution and still leaves a question:
$MyFile4 = preg_replace("[http.+images]","",$MyFile);
echo"<br>$MyFile4<br>;
this gives me /image.jpg . . . I can work with this
Suppose I wanted to get all of the information between http and images . . .
is there a way to do that?
I have been working on this and googling all day and was not getting
anywhere
Hope this will help someone.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
____ The WDVL Discussion List from WDVL.COM ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016
Please include the email address which you have been contacted with.