amitk / Coorporatecatering

A ruby on rails learning project
0 stars 0 forks source link

repetition symbols #8

Open amitk opened 7 years ago

amitk commented 7 years ago

=begin Repetition . * - Zero or more times
. + - One or more times
. ? - Zero or one times (optional) . {n} - Exactly n times . {n,} - n or more times . {,m} - m or less times . {n,m} - At least n and at most m times

Repetition is greedy by default A greedy metacharacter can be made lazy by following it with ? Note Quantifires are greedy, add a ? to make it lazy. =end

p /\d*/ =~ "safdfs434"

p "Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/)

p "".match(/<.+?>/)

p /[[:upper:]][[:lower:]]/.match("Hello")