Testing if a symbol is a valid variable name

Hi,

Is there a function I could use to test if a symbol is an allowed identifier to name a variable as defined in the documentation: https://docs.julialang.org/en/release-0.4/manual/variables/#allowed-variable-names.

More precisely, I am looking for a function is_variable such that

is_variable(:varname_1)

returns true while

is_variable(:+)

returns false.

Thanks,

Antoine

Base.isidentifier(s), where s is either a Symbol or a string, should do what you want.

5 Likes

Thanks. Exactly what I was looking for.