Skip to content

Instantly share code, notes, and snippets.

@raphink
Created July 17, 2013 13:35
Show Gist options
  • Save raphink/6020601 to your computer and use it in GitHub Desktop.
Save raphink/6020601 to your computer and use it in GitHub Desktop.
1.8.7-p371 :001 > target = '/files/etc/toto'
=> "/files/etc/toto"
1.8.7-p371 :002 > spath = '/files/etc/toto/truc/IfModule[3]/directive[6]'
=> "/files/etc/toto/truc/IfModule[3]/directive[6]"
1.8.7-p371 :003 > spath.slice(target.length+1..-1).sub(/(.*)\/directive(?:\[\d+\])?/, '\1')
=> "truc/IfModule[3]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment