Solved

REGEX undesired behavior

Posted on 2008-10-04
6
274 Views
Last Modified: 2012-01-23
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
Comment
Question by:evanj23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22642355
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22645515
how is your language environment (LANG, LC_Type, etc.) set?
0
 

Accepted Solution

by:
evanj23 earned 0 total points
ID: 22645980
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22657503
> .. 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
 
LVL 29

Expert Comment

by:dgofman
ID: 37478729
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question