I've got a variable like {current_url} which contains the full url of the page you are on.

I want to strip out the last segment from it.

Is there a plugin or native EE way of doing that?

Say that variable is example.com/me/you and i want to remove the "you" from the end, how would i do that?

Due to variable url segments, i can't do {segment_2}{segment_3}{segment_4} as "you" might be the second or third or fourth variable.


4 Answers 4


Low's stuff is allways awesome. I was thinking of this, pretty awesome too. http://www.causingeffect.com/software/expressionengine/ce-string?

  • CE String is awesome and indispensable. It's like a Swiss Army Knife.
    – adrienne
    Commented Nov 25, 2012 at 23:14

Found it, the brilliant @low strikes again with a great plugin called Low Replace!

Syntax like:

{exp:low_replace find="you" replace=""}{current_url}{/exp:low_replace}


  • exactly what i was going to suggest.
    – CreateSean
    Commented Nov 22, 2012 at 17:04
  • I'm trying to do exactly that right now - AWESOME!
    – JKM
    Commented Nov 27, 2012 at 1:49

You could also try PHPStringFun and the str_replace function. PHPStringFun lets you run php functions on the template without enabling PHP.

It'll be overly complex for this but is useful if you need to do anything more than just replace text (or use any other phpfunctions).


Surgeree also does regex replace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.