Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reg Exp Help 1

Status
Not open for further replies.

rye8261

Technical User
Jul 6, 2003
359
US
I am trying to change the displayed URL with a reg exp. The goal is for a URL like this:

to be displayed like this, with or without the last "/"

I am very new to reg exp and this is what i have so far.
ereg("([^\\/]*)$", $pathOrUrl, $regs);
echo $regs[0];

but that just displays the index.php?a=...

How can i get the first part of the url?

Thanks for any help

---------------------------------------
 
try this (untested)

ereg("^(\w+)\/\/:([^\/]*)", $pathOrUrl, $regs);


-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Try this, the bit you want will probably be $matches[1]

preg_match("/^(http:\/\/[^\/]+)(\/.*)/i", $URL, $matches);
print_r($matches);



______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top