-2

It is hard to find. I need to write lexer and tokenizer for it. I've got a problem in finding a regex which matches variable names but not string values.

The following should not be matched:

"ala ma kota"
5aalaas

This should be matched:

ala_ma_KOTA999653
l90
a

I already got something like this:

[a-zA-z]\w+

but I don't know how to exclude " chars from the beginning and end of a match.

Thanks for any reply or google links (I couldn't find it - it can be from lmgify ;)).

speakr
  • 4,141
  • 1
  • 22
  • 28
  • possible duplicate of [Regex that matches valid Ruby local variable names](http://stackoverflow.com/questions/3648551/regex-that-matches-valid-ruby-local-variable-names) – Yehuda Katz Jan 17 '13 at 22:45

1 Answers1

0

I interpret variable names as all word character sequences with a min length of 1 and starting with a letter. Your regexp was almost correct then:

^[A-Za-z]\w*$
speakr
  • 4,141
  • 1
  • 22
  • 28