<div dir="ltr"><div>Two more observations which may be worth while being stated explicitly:</div><div><br></div><div>The regexes are expected to be used just against attribute strings, not the complete element xml, or scene xml . I think that is implied by how XML native data types are referenced.<br></div><div>Partial matches do not count as successful. That means, there needs to be an additional check if the matched portion of the string is identical to the string. I think that is implied how the existing regexes are formulated.</div><div><br></div><div>And two more question:</div><div><br></div><div>The existing regexes do not allow for leading white space. It looks like this is inspired by XML spec. regexes: <a href="https://www.w3.org/TR/xmlschema11-2/#decimal">https://www.w3.org/TR/xmlschema11-2/#decimal</a> . However, native XML decimal integers and floats allow leading white space due to the fixed  whiteSpace: collapse restriction.</div><div>Should therefore optional leading white space be added to the existing regexes ? I think so, or alternatively removed from native using types (by not using native types).</div><div>For SF fields which contain multiple numbers, such as SFVec or SFColor, the existing regexes require exactly one space character as separator. What is the rationale for not allowing repeated space characters which may help with formatting ?</div><div><br></div><div>-Andreas</div><div><br></div><div><div class="gmail_quote"><div dir="ltr">On Thu, Jun 7, 2018 at 2:11 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com">andreasplesch@gmail.com</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"><div dir="ltr">Since I got started with the regexes, let's look at SFImage as it is still a TODO.<div><br></div><div><div><a href="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage" target="_blank">http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage</a><br></div><div><br></div><div>appears to be the main (only?) source of the format description.</div><div><br></div><div>We need exactly three decimal non-negative integers followed by a zero or more non-negative decimal or hexadecimal integers.</div><div><br></div><div>There is no mentioning of the separator, so let's look at some example scenes:</div><div><br></div><div><a href="http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/PixelTexture/index.html" target="_blank">http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/PixelTexture/index.html</a><br></div><div><br></div><div>The NIST examples all use space as separator.</div><div><a href="http://www.web3d.org/x3d/tooltips/X3dTooltips.html#PixelTexture" target="_blank">http://www.web3d.org/x3d/tooltips/X3dTooltips.html#PixelTexture</a> examples all use space.<br></div><div><br></div><div><a href="http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html" target="_blank">http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html</a> has a minimum length of 5, presumably as a result of three single digits for wdth, height and components plus two separator characters.<br></div><div><br></div><div>So one question is: Are single commas legal to separate numbers in SFImage from each other ? <a href="http://www.web3d.org/specifications/X3dRegularExpressions.html" target="_blank">http://www.web3d.org/specifications/X3dRegularExpressions.html</a> says commas are only allowed in MF fields, so let's say the answer is no.</div><div><br></div><div>What about leading zeroes ? The general guidance in <a href="http://www.web3d.org/specifications/X3dRegularExpressions.html" target="_blank">http://www.web3d.org/specifications/X3dRegularExpressions.html</a> does not allow leading zeroes.</div><div><br></div><div>There is a requirement to have width x height x component number of pixel values but I am not sure if this requirement can be (easily) checked by a regex.</div><div><br></div><div>Capital letters: <a href="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage" target="_blank">http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage</a> only uses capital A-F in hexadecimal example values but let's say a-f is also allowed since they are used in almost all examples.</div><div><br></div><div><div>Ok, let's give it a try:</div><div><br></div><div>[ \t]*(([0-9]|[1-9][0-9]+)([ ]+|$)){3}(([0-9]|([1-9][0-9]+)|(0x([0-9]|[a-f]|[A-F])+))([ ]+|$))*<br></div><div><br></div><div>In words:</div><div><br></div><div>match any leading white space followed by</div><div>exactly three times the following</div><div> - one of the following</div><div>   - either a single digit (including 0) or</div><div>   - a two or more digit number starting with a 1 to 9 digit</div><div> - followed by either</div><div>  - one or more spaces</div><div>  - or the end of the string (accommodating the default '0 0 0' case)</div><div>then optionally followed zero or more times by</div><div>  - one of the following</div><div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    - either a single digit (including 0) or</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    - a two or more digit number starting with a 1 to 9 digit</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    - 0x followed by at least one of</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">       - a single digit or</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">       - a to f letter or</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">       - A to F letter</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">  - followed by either<br></div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    - one or more spaces</div><div style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    - or the end of the string</div>

</div><div> </div><div>The spaces are written as [ ] for clarity but could be just a space character.</div><div><br></div><div>This allows 0 0 0 as it is the default value. It also allows 1 2 3 without any pixel values.but we do not aim at checking the number of pixel values anyways.</div><div><br></div><div>Any input, in particular examples of problem cases welcome. Since images can be huge it may be necessary to optimize for performance and memory which may require more regex expertise than I can bring myself to acquire.</div><div><br></div><div>-Andreas</div><div><br></div>-- <br><div dir="ltr" class="gmail-m_779339077382617404gmail-m_8036743895285184611gmail-m_-7584617605722078071gmail_signature"><div dir="ltr"><div>Andreas Plesch<br>Waltham, MA 02453</div></div></div></div></div></div>
</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></div>