Can I use a reg-ex for identifiers?
In R identifiers:
Start with A-Za-z, followed by A-Za-z0-9_.
Can also start with a ., but not followed by a digit.
A perl regex might look like: ((\.[A-Za-z_])|([A-Za-z))[A-Za-z0-9_.]*
But, a letter is defined by isalnum(c) -- locale dependent, so accented letters and such are allowed.
Annoying, but not so terrible. You could simple make the regex include all these letters and ignore locale.
(This only applies to letters. The only digits allowed are 0...9).
HORRORS ...
R also lets you quote identifiers (who created this stupid language??)
But, there are special rules that apply to decide if it is a name or a string.
backticks are preferred. For example (pay attention to ' vs ` )
> 'a bad name' = 5
> 'a bad name'
[1] "a bad name"
> 'a bad name'+1
Error in "a bad name" + 1 : non-numeric argument to binary operator
> `a bad name`
[1] 5
> `a bad name` + 1
[1] 6
R Studio colors backticks as identifiers, but not the assignment I show above.