Posted By

noah on 01/09/09


Tagged

regex Shell script ruby howto tricks slice


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


How to find the path to the script that is currently executing


 / Published in: Ruby
 

URL: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/233589

I just realized this kind of regex operation is done with slice in Ruby. In Perl that would be

print 'path/to/file' =~ m{(.*/)};
  1. puts $0.slice(/.*\//)

Report this snippet  

You need to login to post a comment.