W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2012

RegExp support in WebIDL

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Wed, 04 Jul 2012 12:09:58 +0200
Message-ID: <4FF41676.8080809@lachy.id.au>
To: public-script-coord@w3.org
Hi,
   WebIDL currently doesn't support RegExp values.  However, we are 
working on a feature for Opera's extensions where the ability to set a 
value of a dictionary property to a regular expression would be useful.

I believe most other built-in ECMAScript objects can be represented in 
WebIDL.  RegExp seems to be the only built-in ES5 object that can't.

Our use case is for a dictionary that looks something like this:

dictionary Properties {
   (DOMString or RegExp) pattern
   ...
}

When it's the value is set to a DOMString, the match is a simple keyword 
match. When it's a regular expression, it can handle more complicated 
pattern matching.

Possible solutions we could use given the current state of the spec are 
to either:

1. Use (DOMString or object) and then handle evaluating it as a
    regular expression in prose.

2. Define the pattern as a DOMString only, which when set to an ES
    RegExp value, will stringify as "/.../" and can then be parsed
    again. This would require carfully differentiating between strings
    intended for keyword matches and strings intended to be regular
    expressions.

3. Accept it as a wilful violation and move on, which isn't optimal.


Is there any reason to leave RegExp unsupported in WebIDL?

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/
Received on Wednesday, 4 July 2012 10:10:30 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:06 UTC