This looks interesting, but it seems like current selector abilities can handle such case quite easily:
// collect all "input" elements within a form with id "myForm" that are of type "checkbox" and whose name attribute value begins with "selectedLine" : ) $$('#myForm input[type=checkbox][name^=selectedLine]'); Enumerable methods can do this as well: myForm.getInputs('checkbox').findAll(function(el) { return /selectedLine\[\d+\]\[\d+\]/.test(el.name); }) As far as checking whether argument is a regexp - why not just do: object.constructor == RegExp Best, kangax On Apr 16, 7:33 am, SWilk <[EMAIL PROTECTED]> wrote: > Hi, > > I have a form with many checkboxes, which names looks like this > > name='selectedLine[127][23]' > > It is impossible to collect them with Form.getInputs, cause the > numbers in brackets are variable. > Anyway, all the checkboxes' names would match RegExp > /selectedLine\[\d+\]\[\d+\]/ > > I suggest adding support for RegExp matching of input names. > > We can test if the "name" parameter is an RegExp by checking if it > implements the "test" and "exec" regExp methods. If so, we use > name.test(), else we use old method - direct comparison. > > Of course it is possible that not-RegExp object will implement test > and exec methods, but then, I think it is safe to trust that the > programmer knows what (s)he passes to this method. If it is something > random, then i wouldn't made through (name != input.name) comparison > either. > It is also possible to pass any object with test() method witch would > do any test needed, not necessarily an RegExp test. Maybe we even > should'n test for .exec() method? > > This patch works for me:http://swilk.int.pl/form.js-getInputsWithRegExp.diff > > What do you think? > > -- > Regards, > Szymon Wilkołazki --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---