• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

REGEX undesired behavior

I have a regex in a flex (sorry this is flex fast lexical analyzer not adobe flex)  scanner that I am writting that is according to the compiler making another regex I have unmatchable.

The first regex is
[a-zA-Z][a-zA-Z0-9_]*

according to the compiler this first regex will match
"]" and "[" and thus make my regex for them useless.  Why is it telling me this?

I found that if I make the first regex [a-zA-Z][a-z0-9_]* it no longer gives me this warning
0
evanj23
Asked:
evanj23
1 Solution
 
ozoCommented:
I don't see how the first expression will match "]" and "["
If it had been [A-z] or [Z-A], and your character set was ASCII, then it would match "]" and "["
0
 
ahoffmannCommented:
how is your language environment (LANG, LC_Type, etc.) set?
0
 
evanj23Author Commented:
I found a way around this issue, I place the [ ] above the other regex so it has a higher precedence, but am still curious what was going on.   I also thought of [A-z] or [Z-A] but this was not the problem I triple checked my code.  

How do I check my language environment?
0
 
ahoffmannCommented:
> .. I place the [ ] above the other regex
could you please post the complete set of rules

> How do I check my language environment?
printenv
set
0
 
dgofmanCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now