class_docstr: A setting for entering text values limited to alphanumeric + _ values
  
  This can be used for measurement names, object names, etc.
docstr: Validate text as alphanumeric, throwing a validation error if not
  
  text - text to be validated
  
  setting - blame this setting on failure
  
  first_must_be_alpha - True if the first letter has to be alpha or underbar
docstr_tok: ["Validate","text","as","alphanumeric",",","throwing","a","validation","error","if","not","text","-","text","to","be","validated","setting","-","blame","this","setting","on","failure","first_must_be_alpha","-","True","if","the","first","letter","has","to","be","alpha","or","underbar"]
code: def validate_alphanumeric_text(text, setting, first_must_be_alpha):
      """Validate text as alphanumeric, throwing a validation error if not
  
      text - text to be validated
  
      setting - blame this setting on failure
  
      first_must_be_alpha - True if the first letter has to be alpha or underbar
      """
      if first_must_be_alpha:
          pattern = "^[A-Za-z_][A-Za-z_0-9]*$"
          error = (
              'Names must start with an ASCII letter or underbar ("_")'
              " optionally followed by ASCII letters, underbars or digits."
          )
      else:
          pattern = "^[A-Za-z_0-9]+$"
          error = (
              'Only ASCII letters, digits and underbars ("_") can be '
              "used here"
          )
  
      match = re.match(pattern, text)
      if match is None:
          raise ValidationError(error, setting)
  
imports: import re
  from .._text import Text
  from ..._validation_error import ValidationError
label_desc: Use image node_id 3 for calling the Alphanumeric obj's underlying member method code with example usage: obj.validate_alphanumeric_text(text, setting, first_must_be_alpha) without return types