From cbcdb19a47d0a2fa04c72533a338e14f8926d5c6 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 26 Sep 2009 04:07:22 +0200 Subject: AS guide: documents Regexp.unoptionalize --- railties/guides/source/active_support_overview.textile | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index 290b1e441e..abb7ca9491 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -1609,6 +1609,19 @@ Regexp.optionalize('...') # => '(?:...)?' This method is also used by the routing system, it helps in building optional regexp segments. +h4. +unoptionalize(pattern)+ + +The class method +unoptionalize+ is the inverse of +optionalize+ for optional regexps, and the identity for the rest: + + +Regexp.unoptionalize('') # => '' +Regexp.unoptionalize('.?') # => '.' +Regexp.unoptionalize('(?:...)?') # => '...' +Regexp.unoptionalize('\A\w+\z') # => '\A\w+\z' + + +This method is also used in the routes code for building regexps. + h3. Extensions to +Range+ ... -- cgit v1.2.3