Re: Attributes with dashes
Olaf Buwen <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.petal |
|---|---|
| Message-ID | <[email protected]> |
you are right; your example > So the regex needs to look something like this: > > /^\s*([A-Za-z_:][A-Za-z0-9_:.-]*)\s+(.*?)\s*$/ > is rather close to the "perfect" solution, just escape the "." to /^\s*([A-Za-z_:][A-Za-z0-9_:\.-]*)\s+(.*?)\s*$/ Bruno Postle schrieb: > On Tue 04-Jan-2005 at 15:55 +0100, Olaf Buwen wrote: > >> >> "tal:attributes='foo-bar data/foo/bar'" does not work, although XML >> allows attributes with dashes. >> >> As a workaround, I modified the regular expression in >> Petal/Canonicalizer/XML.pm, line 547 from > > >> /^\s*((?:\w|\:)+)\s+(.*?)\s*$/ >> to >> /^\s*((?:[-\w]|\:)+)\s+(.*?)\s*$/ > > > It would be nice if either regex matched the XML specification for > attribute names. Petal could generate attributes like these which I'm > sure are not within the XML spec: > > -foo="whatever" > --bar="whatever" > > This might also cause trouble with the "--value" system for passing > arguments to methods. > > Also I think this is a valid XML attribute: > > foo_2.BAR="whatever" > > So the regex needs to look something like this: > > /^\s*([A-Za-z_:][A-Za-z0-9_:.-]*)\s+(.*?)\s*$/ > > Comments? I'm no regular expression guru. >