Trying to match what is before /../ but after / with regular expressions

Posted by tim on Stack Overflow See other posts from Stack Overflow or by tim
Published on 2010-04-13T06:36:41Z Indexed on 2010/04/13 6:43 UTC
Read the original article Hit count: 196

Filed under:

I am trying to match what is before /../ but after / with regular expressions, but i want it to look back and stop at the first / I feel like I am close but it just looks at the first slash and then takes everything after it like... input is this:

this/is/a/./path/that/../includes/face/./stuff/../hat

and my regular expression is

#\/(.*)\.\.\/#

matching

/is/a/./path/that/../includes/face/./stuff/../

instead of just

that/../ and stuff/../

how can i adapt what i'm doing to work?

© Stack Overflow or respective owner

Related posts about regex