Andrew Timberlake
1/17/2008 10:37:00 AM
> Im just after a bit of clarification with quantifiers in regular
> expressions.
> I just want to be sure of the differences between the quantifiers. so
> for these various regular expressions,
>
> [a-z]* - this will match any amount lower case letters
> [a-z]+ - this will match any amount lower case letters
> (whats difference between + and * in this case?)
> [a-z]+? -
>
> or
>
> \d* - This will match any amount of digits
> \d*? - This will only match none or one number
>
> Please can someone offer some clarification Im still unsure of myself
> with these expresions as I'm new to ruby,
> Thanks,
> Dan
Dan
* matches 0 or more of the preceding pattern
+ matches 1 or more of the preceding pattern
? matches 0 or 1 of the preceding pattern
{n,m} matches n to m of the preceding pattern
I stand to be corrected but I don't believe that *? or +? are valid at all.
Andrew Timberlake
andrew@andrewtimberlake.com
082 415 8283
skype: andrewtimberlake
"I have never let my schooling interfere with my education."
--Mark Twain