re = /(http(s)?:\/\/.)?(www\.)?(?:[-a-zA-Z0-9@:%_\+~#=]{1,63}\.)+[a-z]{2,6}\b((?:[-a-zA-Z0-9@:%_\+~#?&\/\/="]+\.)*[-a-zA-Z0-9@:%_\+~#?&\/\/="]+)?/
str = 'asfd http://gskinner.co.im asfd
asfd m.skinner.com asfd
asfd www.gskinner.com asfd
asfd http://www.gskinner.com asfd
asfd www.gskinner.com?a=1&b=2 asfd
asfd gskinner.com?a="1"%203&b=2 asfd
asfd http://gskinner.com/a/b?c=3 asfd
asfd https://gskinner.com/a/b?c=3 asfd
asfd fdg.f.fg.gskinn.er.com/a/b?c=3 asfd
asfd ffgfgfgfgdfd/dfdfd.df asfd
asfd https://web.whatsapp.com/%F0%9F%8C%90/en asfd
asfd sdfsd://asdfw.asgd asfd
wealth.in..mutual sdf of 10k
wealth.Mutual,dfdfg sdf of 10k
wealth.Mutu/#index al of 10k
wealth.#MutualFundsSIP of 10k
wealth.$MutualFundsSIP of 10k
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html