End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
URI.regexp
regexp(schemes = nil)
lib/uri/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/uri/common.rb, line 272
def self.regexp(schemes = nil)
warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE
DEFAULT_PARSER.make_regexp(schemes)
end
Synopsis
Example
URI::regexp([match_schemes])
Args
match_schemes-
Arrayof schemes. If given, resulting regexp matches to URIs whose scheme is one of the match_schemes.
Description
Returns a Regexp object which matches to URI-like strings. The Regexp object returned by this method includes arbitrary number of capture group (parentheses). Never rely on its number.
Usage
Example
require 'uri' # extract first URI from html_string html_string.slice(URI.regexp) # remove ftp URIs html_string.sub(URI.regexp(['ftp']), '') # You should not rely on the number of parentheses html_string.scan(URI.regexp) do |*matches| p $& end