#2193 Legal Fantom field names

SlimerDude Mon 7 Oct 2013

Hi,

Would anyone know a regex (or similar) for validating if a Str is a legal Fantom field name?

Cheers,

Steve.

brian Mon 7 Oct 2013

Don't think we have sys method, but its:

Bool isIdentifier(Str s)
{
  !s.isEmpty && 
  (s[0].isAlpha || s[0] == '_') && 
  s.all |c| { c.isAlphaNum || c == '_' }
}

Pretty simple to map to regex too

SlimerDude Mon 7 Oct 2013

Cool, that's all I need!

Cheers Brian!

Login or Signup to reply.