Subj : Re: smthing with regular expressions To : eix ät lap ttu ee From : Brendan Eich Date : Fri May 07 2004 12:26 pm Heiko Vainsalu wrote: > Hi > > Hope someone can give me a reason for this. > Need to control a value. And as the condition is quite easy regular > expressions could be used. > > The value must be one of the following: 0, 1, 2, ..., 9, 10 > > When using Regular expressions I would write it intuitively > ^(10)|[0-9]$ > > but when testing then 11 matches this expression just like 1.1 or any > numeric constructions. Where is the trick? The alternation operation | has looser precedence than anchors such as ^ and $. Also, you do not need or want parentheses around 10: ^10$|^[0-9]$ /be .