aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source
diff options
context:
space:
mode:
Diffstat (limited to 'railties/guides/source')
-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+
...