getting regex in a quick way

・1 min read

create snippets

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

# escape.rb

def main()
    ARGV.each do |arg|
        puts(Regexp.escape(arg))
    end
end

if __FILE__ == $0 then
    main()
end

run

$ ./escape.rb "http://www.google.com/"
http://www\.google\.com/

:D

Did you find this post useful? Show some love!
DISCUSSION
Classic DEV Post from Jun 4 '18

Who's looking for open source contributors? (June 4 edition)

Please shamelessly promote your project. Everyone who posted in previous weeks is welcome back this week, as always.

wataken44
Sign up (for free)

dev.to is where software developers stay in the loop and avoid career stagnation.