[pmwiki-devel] Parse Args and hyphens...

Patrick R. Michaud pmichaud at pobox.com
Thu May 17 11:56:17 CDT 2007

On Thu, May 17, 2007 at 06:40:34PM +0200, christian.ridderstrom at gmail.com wrote:
> On Thu, 17 May 2007, The Editor wrote:
> >I've noticed if I try and use parseargs on something like
> >
> >test='blue' test-one='green' test_two='red'
> >
> >The first and third will work, but the second fails. The hyphen in the
> >parameter name blocks ParseArgs from seeing it as a parameter name.
> >
> >Is there a reason for it? Could the function be adapted on a custom 
> >basis to allow this?
> I'm pretty sure you can adjust the pattern to allow a hyphen in the name, 
> but Patrick is the guy to ask.

ParseArgs allows an extra parameter that specifies the pattern used
to parse options.  The default is '(?>(\w+)[:=])'.  If you want to
expand this to allow hyphens, it would probably be

    $args = ParseArgs($str, '(?>(\\w[-\\w]*)[:=])');


More information about the pmwiki-devel mailing list