Class
URegexp
In: uregex.c
Parent: Object

See [docs/UNICODE_REGEXPS] for details of patterns.

Replacement Text

The replacement text for find-and-replace operations may contain references to capture-group text from the find. References are of the form $n, where n is the number of the capture group.

     Character      Descriptions
     $n     The text of capture group n will be substituted for $n. n must be >= 0 and not
     greater than the number of capture groups. A $ not followed by a digit has no special meaning,
     and will appear in the substitution text as itself, a $.
     \     Treat the following character as a literal, suppressing any special meaning. Backslash escaping in
     substitution text is only required for '$' and '\', but may be used on any other character without bad effects.

Valid URegexp options are: COMMENTS, MULTILINE, DOTALL, IGNORECASE, which can be OR‘ed.

All Methods

===, =~, match, new, split, to_u,
Public Class methods
URegexp.new(str [,options])
URegexp.new(regexp)

Constructs a new regular expression from pattern, which can be either a UString or a URegexp.

Public Instance methods
rxp === str => true or false

Case Equality—Synonym for URegexp#=~ used in case statements.

   a = "HELLO".u
   case a
   when ure("^[a-z]*$"); print "Lower case\n"
   when ure("^[A-Z]*$"); print "Upper case\n"
   else;            print "Mixed case\n"
   end

produces:

   Upper case
uregex.match(str) => matchdata or nil
uregex =~ (str) => matchdata or nil

Returns a UMatch object describing the match, or nil if there was no match.

   ure("(.)(.)(.)").match("abc".u)[2]   #=> "b"
uregex.match(str) => matchdata or nil
uregex =~ (str) => matchdata or nil

Returns a UMatch object describing the match, or nil if there was no match.

   ure("(.)(.)(.)").match("abc".u)[2]   #=> "b"
uregex.split(str, limit)

Divides str into substrings based on a regexp pattern, returning an array of these substrings. str is divided where the pattern matches.

uregex.to_u

Returns UString of this URegexp pattern.