getting regex in a quick way

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!
Classic DEV Post from Jun 18

What are your programming blogs?

Hi. I need programming blogs to read. So, what are your programming blogs? You ...

READ POST
Follow @aligoren to see more of their posts in your feed.
wataken44
Member since Nov 15, 2017
Trending on dev.to
How to deal with being laid off?
#work #job #development #discuss
What are your programming blogs?
#discuss
Follow Friday!
#discuss
How do you get a decent estimate on the time it will take to complete a task?
#discuss #work
Ever feel like you have "Programming Synesthesia"?
#discuss #programming #productivity
Postgres or mysql
#discuss
Back to basics: Naming
#naming #javascript #programming #discuss
Does anyone else feel bothered when people term us as coders instead of developers or programmers..?
#discuss