Method: Gem::URI.regexp

Defined in:
lib/rubygems/vendor/uri/lib/uri/common.rb

.regexp(schemes = nil) ⇒ Object

Synopsis

Gem::URI::regexp([match_schemes])

Args

match_schemes

Array of schemes. If given, resulting regexp matches to URIs whose scheme is one of the match_schemes.

Description

Returns a Regexp object which matches to Gem::URI-like strings. The Regexp object returned by this method includes arbitrary number of capture group (parentheses). Never rely on its number.

Usage

require 'rubygems/vendor/uri/lib/uri'

# extract first Gem::URI from html_string
html_string.slice(Gem::URI.regexp)

# remove ftp URIs
html_string.sub(Gem::URI.regexp(['ftp']), '')

# You should not rely on the number of parentheses
html_string.scan(Gem::URI.regexp) do |*matches|
  p $&
end


299
300
301
302
# File 'lib/rubygems/vendor/uri/lib/uri/common.rb', line 299

def self.regexp(schemes = nil)# :nodoc:
  warn "Gem::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
  DEFAULT_PARSER.make_regexp(schemes)
end