Permalink
Browse files

AS guide: documents Regexp.unoptionalize

  • Loading branch information...
1 parent ee289f4 commit cbcdb19a47d0a2fa04c72533a338e14f8926d5c6 @fxn fxn committed Sep 26, 2009
Showing with 13 additions and 0 deletions.
  1. +13 −0 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+
...

0 comments on commit cbcdb19

Please sign in to comment.