prev - up - next - index


The Regexp is the class for regular expression matching. Regular expression literals are enclosed by slashes like:

/^this is regexp/

In other way, you can create the regular expression object using:



Class Methods:

compile(string[, casefold])
new(string[, options])

Compiles the string into a regular expression object. If second argument given, and its value is true, then the created regexp object becomes case-insensitive. the value of the second argument is Fixnum, it must be bitwise-or of Regexp::IGNORECASE and Regexp::EXTENDED.


Insert escape characters before regular expression special characters in the string. Returns the newly created strings.


self =~ string
self === string

Returns an index of the matching place in the string, if matched. Returns nil if not matched. The index of the first character is 0.

~ self

Matches with the value of the default variable ($_). Behaves like:

self =~ $_

Returns true if the Regexp is compiled as case-insensitive.


Returns the orginal string form of the regular expression.

prev - up - next - index