Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created February 16, 2010 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/305520 to your computer and use it in GitHub Desktop.
Save igaiga/305520 to your computer and use it in GitHub Desktop.
replace region using ruby regexp
; replace region using ruby regexp
(defun ruby-gsub(regexp dst)
(interactive "sruby -p -e '$_.gsub!(/regexp/, 'dst')' regexp: \nsruby -p -e '$_.gsub!(/regexp/, 'dst')' [regexp: /%s/ ] dst:" )
(let (( ruby_str (concat "ruby -p -e '$_.gsub!(/" regexp "/,%q`" dst "`)' ")))
; (message ruby_str) ;debug
(shell-command-on-region (region-beginning) (region-end) ruby_str t t)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment