Solved

Matching a breadcrumb style URL

Posted on 2008-10-28
3
223 Views
Last Modified: 2010-05-18
Hello

I need to do a regex replace of a URL for example:

http://localhost/index.php?page=About_Us&page=Our_Address&page=Map

this needs to be re-written as:

http://localhost/About_Us/Our_Address/Map

Does anyone know how this can be done for multiple instances of page=?

Thanks

Jonathan
0
Comment
Question by:jwfranklin
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 125 total points
Comment Utility

echo preg_replace('#(?<=^http://localhost)[^?]*\?page=|&page=#','/',$sourcestring);

Open in new window

0
 
LVL 1

Author Closing Comment

by:jwfranklin
Comment Utility
Spot on, that works fine. Thanks
0
 
LVL 27

Expert Comment

by:ddrudik
Comment Utility
Thanks for the question and the points.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now