Hi

I may have misread your post (I do that a lot :) ) but might this help?

<?
$string =
'http://localhost/m-ysite/editor/plugins/../../../images/image.jpg';
preg_match('/http:\/\/(.+)(\/images\/.+)/i', $string, $match);
var_dump($match);
?>

This gives you:

array(3) {
  [0]=>
  string(65)
"http://localhost/mysite/editor/plugins/../../../images/image.jpg";
  [1]=>
  string(41) "localhost/m-ysite/editor/plugins/../../.."
  [2]=>
  string(17) "/images/image.jpg"
}

HTH

Dan
-----Original Message-----
From: loren wolsiffer [mailto:[EMAIL PROTECTED] 
Sent: 15 February 2006 20:57
To: [email protected]
Subject: RE: [wdvltalk] Regex help

>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

_________________________________________________________________
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.


____ • 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.

Reply via email to