Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have this URL:

http://exampleFixed.helloFixed.com/randomValues/randomValues/randomValue/randomValues/randomValues/randomValues/randomValues/randomValues/endFixed.htm

If you see there are 9 bars from .com to .htm And I want to replace ALL that URL to make it dissapear. Something like this:

 <?
    preg_replace ('theRegexRequired', '', $url);
 ?>

My try but I don't know how to code so many bars:

preg_replace('/http://exampleFixed.helloFixed.com\/(.+)\/endFixed.htm/i','',$url);

Thank you very much!

share|improve this question
I don’t even know PHP, but, just from general experience, I have to wonder: shouldn’t it be '/http:\/\/exampleFixed.helloFixed.com… (i.e., put a backslash before every slash in the regex)? – Scott Dec 13 '12 at 22:57

closed as off topic by SLaks, RedGrittyBrick, Simon Sheehan, ChrisF, Indrek Dec 14 '12 at 0:01

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.