I guess, you are using ruby on Windows OS and cmd.exe.(from [i386-mingw32])
It has differ from UNIX shell family.
This probrem looks from quotaions.

base quotation change ' to "" on cmd.exe

ruby -v -e "puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ 'ABCD1234' )"
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
0

ruby -v -e "puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ 'ABCDE123' )"
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]


ruby -v -e "puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ 'ABCD12345' )"
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]


ruby -v -e "puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ 'ABCDE12345' )"
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

2012/1/21 Straff Walton <straff_walton / yahoo.com.au>:
> regex for matching 1 to 4 caps alpha, followed by 1 to 4 digits seems to
> fail for 5 alpha (tho not 5 digits)
>
> see examples below, 1, 3 and 4 give expected response, but 2 does not.
> Using "http://myregexp.com/" gives expected results (example 2 does not
> match)
>
> # 1
> ruby -v -e 'puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ "ABCD1234" )'
> ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
> 0
>
> # 2
> ruby -v -e 'puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ "ABCDE1234" )'
> ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
> 1
>
> # 3
> ruby -v -e 'puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ "ABCD12345" )'
> ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
>
> # 4
> ruby -v -e 'puts( /^[A-Z]{1,4}[0-9]{1,4}$/ =~ "ABCDE12345" )'
> ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
>
> --
> Posted via http://www.ruby-forum.com/.
>