I have "/foo/bar/url/"
coming straight after my domain name.
What I want is to find penultimate slash symbol in my string and replace it with slash symbol + hashtag. Like so: from /
to /#
(The problem is not how to get URL, but how to handle it)
How this could be achieved? What is the best practice for doing stuff like that? At the moment I'm pretty sure that I should use str_replace();
UPD. I think preg_replace()
would be suitable for my case. But then there is another problem: what should regexp look like in order to make my issue solved?
P.S. Just in a case I'm using SilverStripe
framework (v3.1.12)