I'm having a regex blackout here. How do I capture a negative lookbehind pattern again?
I'm trying to remove the scheme (including ://) of a uri unless it is http/https. I'm half way there (or I thought I was, the pattern below doesn't even compile), but I forgot how to actually capture the negative pattern:
preg_replace( '~^(?<!https?)://~', '', $uri );
How can I do this, again?
Just a quick thought:
preg_replace ('#^((http[s]{0,1}://)|([a-z]+://))#i', '$2', $uri);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With