<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_8036743895285184611gmail-m_-7584617605722078071gmail_signature"><div dir="ltr"><div>Andreas Plesch<br>Waltham, MA 02453</div></div></div></div></div></div>