r"""Determine whether or not the given string is a valid alphanumeric string. Parameters ---------- name : str An alphanumeric identifier. Returns ------- result : bool ``True`` if the name is valid, else ``False``. Examples -------- >>> va
(name)
| 232 | # |
| 233 | |
| 234 | def valid_name(name): |
| 235 | r"""Determine whether or not the given string is a valid |
| 236 | alphanumeric string. |
| 237 | |
| 238 | Parameters |
| 239 | ---------- |
| 240 | name : str |
| 241 | An alphanumeric identifier. |
| 242 | |
| 243 | Returns |
| 244 | ------- |
| 245 | result : bool |
| 246 | ``True`` if the name is valid, else ``False``. |
| 247 | |
| 248 | Examples |
| 249 | -------- |
| 250 | |
| 251 | >>> valid_name('alpha') # True |
| 252 | >>> valid_name('!alpha') # False |
| 253 | |
| 254 | """ |
| 255 | identifier = re.compile(r"^[^\d\W]\w*\Z", re.UNICODE) |
| 256 | result = re.match(identifier, name) |
| 257 | return result is not None |