[whatwg] alternatives/grouping in pattern attributes in Web Forms

mqmq87 at web.de wrote:
> This text in section 2.6 doesn't seem to consider alternatives and grouping:
> 
> | Thus, using the ^ character anywhere other than at the start of the pattern,
> | or the $ character anywhere other than at the end of the pattern, prevents
> | the pattern from matching anything (unless the characters are escaped or
> | part of a range).
> 
> This is wrong (and what means "range"? should this read "CharacterClass"?).
> In pattern="[0-9]+$|^0[xX][0-9a-fA-F]+" they would be even required to prevent
> matching "123xyz", "abc0x0" or similar values, unless the whole string is
> enclosed in parentheses.
> 
> More intuitive would be an implicit enclosure of the attribute value between
> "^(?:" and ")$" instead of plain ^ and $ to construct the actual regular
> expression.
> 

I'm in favour of this.

As previously mentioned:

http://listserver.dreamhost.com/pipermail/whatwg-whatwg.org/2006-April/006182.html

it will lead to more readable markup:

<input type="text" pattern="(red|green|blue)">

compared with:

<input type="text" pattern="red|green|blue">

-dean

Received on Saturday, 22 April 2006 11:51:44 UTC