[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

why does this regular expression match?

dominique.plante@gmail.com

3/10/2006 4:35:00 AM

Using Test::Unit:

r1 = /a*/
assert_nil,'A' =~ r1

The error I get implies that it would match in the same way that the
following would match
'a' =~ r1

Can anyone offer any suggestions?

Thanks!
Dominique

ps. done a google search on Test::Unit lately?

1 Answer

Pete Elmore

3/10/2006 4:51:00 AM

0

The asterisk means "Zero or more of these". You may want to use /a+/
(One or more 'a's).

On 09/03/06, dominique.plante@gmail.com <dominique.plante@gmail.com> wrote:
> Using Test::Unit:
>
> r1 = /a*/
> assert_nil,'A' =~ r1
>
> The error I get implies that it would match in the same way that the
> following would match
> 'a' =~ r1
>
> Can anyone offer any suggestions?
>
> Thanks!
> Dominique
>
> ps. done a google search on Test::Unit lately?
>
>
>