Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Ruby Programming/Reference/Objects/Regexp

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Regexp Regular Expressions 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. oniguruma 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. Simplifying regexes Strategy: name them, then combine them. float = /[\d]+\.[\d]+/ complex = /[+-]#{float}\.#{float}/ Helper websites "rubular":http://rubular.com lets you test your regexps online Alternative Regular Expression Libraries Some other wrappers exist: PCRE Boost Regex