Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

stringlib::validIdent

Validate identifier name

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

stringlib::validIdent(string)

Description

stringlib::validIdent(string) returns TRUE, when string is a valid identifier name, otherwise FALSE.

A valid identifier name in MuPAD® must follow the rules:

  • The first character must be a letter or the character "_".

  • All following characters must be letters or digits or the character "_".

  • An identifier consists of at least one character up to 512 characters.

Names in backticks ` are not determined as valid names.

Examples

Example 1

The example splits a set of names into valid identifier names and invalid identifier names:

split({"a", "1", "_111", "____", "A0b.C", "MuPAD", "1ABCDE", "xyz00"},
      stringlib::validIdent)

stringlib::random called with option Name returns always valid identifier names. The function map applies stringlib::validIdent to each of the 1000 generated random names:

map({stringlib::random(1..10, Name) $ k = 1..1000},
    stringlib::validIdent)

Parameters

string

A string

Return Values

TRUE or FALSE

See Also

MuPAD Functions

Was this topic helpful?