[x3d-public] X3D Regex

Andreas Plesch andreasplesch at gmail.com
Wed Jun 6 16:04:52 PDT 2018


On Wed, Jun 6, 2018 at 4:51 PM, Joseph D Williams <joedwil at earthlink.net>
wrote:

>
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Andreas Plesch <andreasplesch at gmail.com>
> *Sent: *Wednesday, June 6, 2018 10:39 AM
> *To: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *Re: [x3d-public] X3D Regex
>
>
>
> > Date: Wed, 6 Jun 2018 09:23:09 -0700
>
> > From: Don Brutzman <brutzman at nps.edu>
>
> > To: X3D Graphics Working Group <x3d at web3d.org>
>
> > Cc: X3D Graphics public mailing list <x3d-public at web3d.org>, "Humanoid
>
> >         Animation (H-Anim) Working Group" <h-anim at web3d.org>
>
> > Subject: [x3d-public] X3D teleconference 5 JUN 2018 minutes: HAnim
>
> >         DIS, X3D Regex, Web3D 2018 and X3Dv4
>
> >
>
> ...
>
> >         X3D Regular Expressions (regexes)
>
> >         http://www.web3d.org/specifications/X3dRegularExpressions.html
>
> >
>
> > Vince reports that MFInt32 problem stack-overflow error still remains
> when running X3D Schematron locally.  He will post the abridged example
> that is still failing, hopefully that will help our test efforts.
>
> >
>
> > MFInt32 regex pattern:
>
> >
>
> >         ((\+|\-)?(0|[1-9][0-9]*)?( )?(,)?( )?)*
>
> >         http://www.web3d.org/specifications/X3dRegularExpressions.html#
> MFInt32
>
>
>
> >> I am looking at this regex and have a few questions.
>
>
>
> >> All groups are optional, so it seems to also match an empty string "".
>
> >> Perhaps not a problem, or even intentional.
>
>
>
> Totally intentional. We need the ability to legally load the node with no
> content then later, prior to actually running the scene. Add some attr
> content.
>
>
Yes, so the question is really if an empty string is a legal value. It may
be intended as a signal to use the default value.


> >> It matches a mix of commas and spaces, for example ",,,  , ,, ,,  ".
>
> >> This does not look like an acceptable MFInt32 value.
>
>
>
> Well, either space or comma is legal sep. Mix reads poorly but legal if
> number of
>
>
Not sure if there are no digits and just commas and spaces. "1,,2,,3" also
matches. but I doubt that skipping entries is legal.


> >> The second group (0|[1-9][0-9]*) : This is harder to understand. It
>
> seems to want to address leading zeros. Why not just use ([0-9]*) ?
>
> Using https://regexr.com/ and https://regex101.com/ I could not come
>
> up with a pattern where these expressions were not equivalent. What
>
> would be an example where ([0-9]*) would not work ?
>
>
>
> leading zero for decimal value?
>

[0-9]* matches 012 as well, so still looking for an example.


>
>
> >> http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/
> EncodingOfFields.html#SFInt32
>
> allows hexadecimal values, using 0x prefix. I have never seen this but
>
> the regex would not match, eg. produces a false negative.
>
>
>
> Looks like hex needs better regex.
>
>
>

Tempted to give it a try, starting with SFInt32:
/[ \t]*[-|+]?((0x([0-9]|[a-f]|[A-F])+)|[0-9]*)[ \t]*/

Translation: optional whitespace followed by optional plus or minus signs
followed by
either 0x followed by a at least one digit or a to f or A to F letter
or by zero or more digits
followed by white space.

Is tab legal white space ? Is whitespace after the plus/minus sign allowed
? Hm, I guess so.

Testing this regex shows it works pretty well. One issue that it matches "
+  " without any digits. One could require at least one digit but then the
empty string does not match any more. So one could make the complete  regex
optional:

/([ \t]*[-|+]?[ \t]*((0x([0-9]|[a-f]|[A-F])+)|[0-9]+)[ \t]*)?/

How does that look for SFInt32 ? There is \d for digits and \s for white
space but I am not sure how widely supported these are.
/(\s*[-|+]?\s*((0x(\d|[a-f]|[A-F])+)|\d+)\s*)?/

Andreas

>> -Andreas
>
>
>
> Thanks and Best,
>
> Joe
>
>
>
> --
>
> Andreas Plesch
>
> Waltham, MA 02453
>
>
>
> _______________________________________________
>
> x3d-public mailing list
>
> x3d-public at web3d.org
>
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
>
>



-- 
Andreas Plesch
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180606/f3b79fd6/attachment-0001.html>


More information about the x3d-public mailing list