[x3d-public] X3D Regex

Joseph D Williams joedwil at earthlink.net
Wed Jun 6 16:38:14 PDT 2018



Sent from Mail for Windows 10

From: Andreas Plesch
Sent: Wednesday, June 6, 2018 4:05 PM
To: Joseph D Williams
Cc: X3D Graphics public mailing list
Subject: Re: [x3d-public] X3D Regex



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


 
 
From: Andreas Plesch
Sent: Wednesday, June 6, 2018 10:39 AM
To: X3D Graphics public mailing list
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. 

Fine observation. The default value may be the empty string.

>> It matches a mix of commas and spaces, for example ",,,  , ,, ,,  ".
That is an error. Look at the entire range of X3DFields. I don’t think we want to allow a comma inside a tuple, just blank or comma between fields. 
>> 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. 

Matches what, there is a long list of X3DFOe;d forms and X3DArrayFIeld forms. Pretty sure that “,,” has got to be an error. However, look at implementations and see that most can be flexible to give the copy/paste or hand coder a break and at least not kill. . 
 
>> 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.

012 is the same as 12 so maybe intent is leading 0 in decimals
There are fields where a 0 is legal. Again, I think there is a regex for every X3D field and X3DArrayField type,. 
 
 
>> 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]*)?/

So, for this one, the correct answer is Either this regex or the empty string. Seems like we ought to be able to say that. Esp for MFs where the [] is signal for empty

>>> 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*)?/

Has any toolmaker shown their regex? I don’t know what is the spec for ww3regex. 

>> -Andreas
 
Thanks and Best, 
Joe

This mail thing I have gets lost in the processing very easy
 
-- 
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/9736df1d/attachment.html>


More information about the x3d-public mailing list