# Testing if a symbol is a valid variable name

**URL:** https://discourse.julialang.org/t/testing-if-a-symbol-is-a-valid-variable-name/4975
**Category:** General Usage
**Created:** [July 20, 2017, 12:51pm UTC](https://discourse.julialang.org/t/testing-if-a-symbol-is-a-valid-variable-name/4975 "2017-07-20T12:51:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![antoine-soubret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-soubret/32/3249_2.png) [@antoine-soubret](https://discourse.julialang.org/u/antoine-soubret)
#### Post date: [July 20, 2017, 12:51pm UTC](https://discourse.julialang.org/t/testing-if-a-symbol-is-a-valid-variable-name/4975/1 "2017-07-20T12:51:49Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [July 20, 2017, 1:14pm UTC](https://discourse.julialang.org/t/testing-if-a-symbol-is-a-valid-variable-name/4975/2 "2017-07-20T13:14:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![antoine-soubret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-soubret/32/3249_2.png) [@antoine-soubret](https://discourse.julialang.org/u/antoine-soubret)
#### Post date: [July 21, 2017, 11:00am UTC](https://discourse.julialang.org/t/testing-if-a-symbol-is-a-valid-variable-name/4975/3 "2017-07-21T11:00:05Z")

</div>

Thanks. Exactly what I was looking for.
