On Sun, 24 Feb 2002, Stefan Seifert <[EMAIL PROTECTED]> wrote,

> Hasanuddin Tamir wrote:
>
> >I don't personally see any problem to include colon in the allowed
> >characters. But why the second alternatif is more difficult to parse? If
> >you have consistent syntax, it should be simpler.
> >
> >    m!^(\w+):(\w+?)/(\w+)\.(\w+)$!;
> >    $object = $1;
> >    $id = $2;
> >    $method = $3;
> >    $attr = $4;
> >
> >    m!^(\w+?)/(\w+?)/(\w+)\.(\w+)$!;
> >    $object = $1;
> >    $id = $2;
> >    $method = $3;
> >    $attr = $4;
> >
>
> The problem is that each object may have subobjects. And additionally
> the id is optional and so is the method.
> So the following cases would be valid:
> OBJECT.SUBOBJECT.ATTRIBUTE
> OBJECT/METHOD
> OBJECT:ID.ATTRIBUTE
> OBJECT.SUBOBJECT/METHOD
> and more
>
> the only special case is that only the root object may have an id since
> subobjects already have one through the relationship to their parent.
> But thanks for the regular expressions, maybe I can use them with a
> little tweaking :)

The optional part can be matched with ? after the token. It's different
from ? used for quantifier.

    /(\w+?):(\w+)?/;

The first ? following + makes the regex non-greedy, the second one
following the whole (\w+) makes that part optional, so $2 may or may not
contain something.

Well, I can see the parsing problem is not about using colon or dot :-)


rgd
-- 
san->http(www.trabas.com)
{If Linux doesn't have solution, you have the wrong problem}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to