Stream: terminology
Topic: Regex on name properties
Peter Jordan (Mar 09 2019 at 03:04):
name.matches('[A-Z]([A-Za-z0-9_]){0,254}')
Interestingly, this doesn't permit the use of hyphens which (depending on your test engine of choice) may result in the warning ... "Name should be usable as an identifier for the module by machine processing applications such as code generation". One would think that as hyphens are used in concept identifiers by some code systems (e.g. LOINC), they would be permitted in name properties?
Lloyd McKenzie (Mar 09 2019 at 03:12):
The purpose of 'name' is to be software friendly - it should be a valid class name. And dashes aren't allowed in class names in most languages because '-' is an operator.
Lloyd McKenzie (Mar 09 2019 at 03:13):
You can translate the dashes to underscores for the purposes of generating a valid name if you like.
Peter Jordan (Mar 09 2019 at 03:29):
That makes sense - I'd never equated those name properties with class and object names in source code (doh - although in my implementation, using the C# library, these are object property names, not object or class names). Good solution, I'd just coded it myself! Also have to ensure that the first character is an upper case letter.
Last updated: Apr 12 2022 at 19:14 UTC