A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.wikibooks.org/wiki/Ruby_Programming/Reference/Objects/Regexp below:

Ruby Programming/Reference/Objects/Regexp - Wikibooks, open books for an open world

From Wikibooks, open books for an open world

Class Regexp holds a regular expression, used to match a pattern of strings.

Regular expressions can be created using /your_regex_here/ or by using the constructor "new".

>> /a regex/
>> /a case insensitive regex/i

or use the new constructor with constants, like

>> Regexp.new('a regex')
>> Regexp.new('a regex', MULTILINE)

To see all available creation options, please see the regex rdoc.

Starting with 1.9, ruby has a new Regular Expression engine (oniguruma), which is slightly faster and more powerful, as well as encoding aware/friendly. To see a good explanation of how it works, please see its rdoc.

Strategy: name them, then combine them.

float = /[\d]+\.[\d]+/
complex = /[+-]#{float}\.#{float}/

"rubular":http://rubular.com lets you test your regexps online

Some other wrappers exist:

PCRE Boost Regex


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4