# \[Bug #909\] optparse with regexp

**URL:** <https://www.ruby-forum.com/t/bug-909-optparse-with-regexp/156097>\
**Category:** Development\
**Created:** [December 20, 2008, 3:52pm UTC](https://www.ruby-forum.com/t/bug-909-optparse-with-regexp/156097 "2008-12-20T15:52:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubikitch\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@rubikitch\_S](https://www.ruby-forum.com/u/rubikitch_S)\
**Post date:** [December 20, 2008, 3:52pm UTC](https://www.ruby-forum.com/t/bug-909-optparse-with-regexp/156097/1 "2008-12-20T15:52:44Z")

</div>

Bug #909: optparse with regexp  
[http://redmine.ruby-lang.org/issues/show/909](http://redmine.ruby-lang.org/issues/show/909)

e$B5/I\<\<Te(B: rubikitch .  
e$B%9%F!\<%?%9e(B: Open, e$BM%@hEYe(B: Normal

optparsee$B$G%\*%W%7%g%s0z?t$K%^%C%A$9$Y$-@55,I=8=$r;XDj$7$?\>l9g$N5sF0$,JQ$o$C$F$$$^$9!#e(B

#!/usr/local/bin/ruby  
require ‘optparse’  
opts = {}  
ARGV.options do |o|  
o.on(“-T [level]”, /^[0-4]$/) {|x| opts[:T] = x }  
o.parse!  
end  
puts “opts=#{opts.inspect}”

$ ruby187p72 -v optparse-regexp.rb -T1  
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]  
opts={:T=\>“1”}  
$ ruby18 -v optparse-regexp.rb -T1  
ruby 1.8.7 (2008-12-16 revision 20784) [i686-linux]  
opts={:T=\>[“1”]}

---

<div class="post-metadata">

**Author:** ![rubikitch\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@rubikitch\_S](https://www.ruby-forum.com/u/rubikitch_S)\
**Post date:** [December 21, 2008, 4:28am UTC](https://www.ruby-forum.com/t/bug-909-optparse-with-regexp/156097/2 "2008-12-21T04:28:04Z")

</div>

e$B%A%1%C%He(B #909 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!\<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B  
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

## Applied in changeset r20895.

[http://redmine.ruby-lang.org/issues/show/909](http://redmine.ruby-lang.org/issues/show/909)
