aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-09-26 04:07:22 +0200
committerXavier Noria <fxn@hashref.com>2009-09-26 04:07:22 +0200
commitcbcdb19a47d0a2fa04c72533a338e14f8926d5c6 (patch)
tree0c93ca13b257fc43a1310fb2bfa623a989472f3e /railties/guides
parentee289f42c618780ed7438867ca26961b29a942a7 (diff)
downloadrails-cbcdb19a47d0a2fa04c72533a338e14f8926d5c6.tar.gz
rails-cbcdb19a47d0a2fa04c72533a338e14f8926d5c6.tar.bz2
rails-cbcdb19a47d0a2fa04c72533a338e14f8926d5c6.zip
AS guide: documents Regexp.unoptionalize
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/active_support_overview.textile13
1 files changed, 13 insertions, 0 deletions
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:
+
+<ruby>
+Regexp.unoptionalize('') # => ''
+Regexp.unoptionalize('.?') # => '.'
+Regexp.unoptionalize('(?:...)?') # => '...'
+Regexp.unoptionalize('\A\w+\z') # => '\A\w+\z'
+</ruby>
+
+This method is also used in the routes code for building regexps.
+
h3. Extensions to +Range+
...