<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Jun 8, 2018 at 2:19 AM Don Brutzman <<a href="mailto:brutzman@nps.edu">brutzman@nps.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">i tried testing this against PixelTexture value<br>
<br>
        2 4 3 0xff0000 0xffff00 0x007700 0xff0077 0x0000ff 0xff7700 0x00ff77 0x888888<br>
<br>
from scene<br>
<br>
        <a href="http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter05AppearanceMaterialTextures/PixelTexture.x3d" rel="noreferrer" target="_blank">http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter05AppearanceMaterialTextures/PixelTexture.x3d</a><br>
<br>
using <a href="https://regex101.com" rel="noreferrer" target="_blank">https://regex101.com</a> and that tests satisfactorily.<br>
<br>
however the default value of '0 0 0' fails according to XML Spy, so there is still a problem here...<br></blockquote><div><br></div><div>I could confirm that this is due to XML regex expressions not considering anchors, in particular the $ end of string anchor.</div><div><br></div><div>Without anchors the regex becomes longer and a bit more complicated, still not allowing leading zeroes or commas:</div><div><br></div><div>^\s*(\d|[1-9]\d+)(\s+(\d|[1-9]\d+)){2}(\s+((0x([a-f]|[A-F}|\d]){1,8})|[1-9]\d+|\d))*\s*$ (allowing for leading and trailing white space, and anchoring)<br></div><div><br></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(\d|[1-9]\d+)(\s+(\d|[1-9]\d+)){2}(\s+((0x([a-f]|[A-F}|\d]){1,8})|[1-9]\d+|\d))* (untested XML version which is implicitly anchored, assuming the whitespace collapsing restriction)</span><br></div><div><br></div><div><a href="https://regex101.com/r/CJ1h80/4/tests">https://regex101.com/r/CJ1h80/4/tests</a><br></div><div><br></div><div>lets everybody test and improve this regex with some of the more challenging cases as unit tests, including the default 0 0 0 case.</div><div><br></div><div>It is more important to come up with examples which almost match but actually should not match than testing conforming examples such as the web3d example library. Of course there should not be any false positives, eg. not matching examples which are in fact fine.</div><div><br></div><div>The new regex had to split the matching of the 3 initial integers into two parts. First matching the first integer, then matching at least one whitespace followed by an integer, twice.</div><div>For optional value matching, the order is now at least one whitespace followed by a number rather than number then whitespace, to avoid requiring whitespace at the very end. This in turn required an ordering of the or number branches to hex, then multidigits, then single digits for reasons I hesitate to fully explore but probably having to do with greediness.<br></div><div>The new regex also uses the \d and \s classes for conciseness, as well as Leonards idea to limit hex values to at most 8 characters.</div><div><br></div><div>TODO: clarify commas, spec. says commas in SF fields are whitespace, so should be allowed. But allowing in SF fields and then not allowing them in the corresponding MF field for other than set separation is quite confusing.</div><div><br></div><div>Give it a spin, -Andreas</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
in any case, great start! have added it to X3D v4.0 schema for further experimentation, in this case under the annotations until working better.<br>
<br>
deployed online.  however can't get svn to work here so checkins will be another time.<br>
<br>
<a href="http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html" rel="noreferrer" target="_blank">http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html</a><br>
<br>
<br>
On 6/7/2018 11:11 AM, Andreas Plesch wrote:<br>
> Ok, let's give it a try:<br>
> <br>
> [ \t]*(([0-9]|[1-9][0-9]+)([ ]+|$)){3}(([0-9]|([1-9][0-9]+)|(0x([0-9]|[a-f]|[A-F])+))([ ]+|$))*<br>
> <br>
> In words:<br>
> <br>
> match any leading white space followed by<br>
> exactly three times the following<br>
>   - one of the following<br>
>     - either a single digit (including 0) or<br>
>     - a two or more digit number starting with a 1 to 9 digit<br>
>   - followed by either<br>
>    - one or more spaces<br>
>    - or the end of the string (accommodating the default '0 0 0' case)<br>
> then optionally followed zero or more times by<br>
>    - one of the following<br>
>      - either a single digit (including 0) or<br>
>      - a two or more digit number starting with a 1 to 9 digit<br>
>      - 0x followed by at least one of<br>
>         - a single digit or<br>
>         - a to f letter or<br>
>         - A to F letter<br>
>    - followed by either<br>
>      - one or more spaces<br>
>      - or the end of the string<br>
<br>
<br>
all the best, Don<br>
-- <br>
Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Andreas Plesch<br>Waltham, MA 02453</div></div></div></div>