Google Answers Logo
View Question
 
Q: Regular expression to parse variable names ( No Answer,   2 Comments )
Question  
Subject: Regular expression to parse variable names
Category: Computers > Programming
Asked by: bobopico-ga
List Price: $15.00
Posted: 14 Jul 2006 16:51 PDT
Expires: 14 Jul 2006 21:45 PDT
Question ID: 746454
Regular expression to parse variables or words from a string, but not
function names.  Example:
LTE(TARGET_SCENARIO_NO,0)*0 +
(GT(TARGET_SCENARIO_NO,0)*(NET_REVENUE-GROSS_MARGIN+TARGET_GROSS_MARGIN))


If I use a regular expression that looks like:

\b([a-zA-Z])(\w+)?\b

I can get all the words separated.  However, it also gets LTE( and GT(
which I want ignored because they are functions.  A function is
defined because the ( comes right after the word.

Clarification of Question by bobopico-ga on 14 Jul 2006 16:51 PDT
I am using .NET 2.0.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Regular expression to parse variable names
From: ysf-ga on 14 Jul 2006 20:00 PDT
 
Hi,

at first, please excuse my bad english :/
A common trick is to parse everything allowed and then negate that expression. 

([a-zA-Z]\w+)[^\w(]

with your example and only got the variable back. The ^ sign in
brackets that we allow everything besides \w and (

Have fun :)
Subject: Re: Regular expression to parse variable names
From: ysf-ga on 14 Jul 2006 20:08 PDT
 
Hi,

at first, please excuse my bad english :/
A common trick is to parse everything allowed and then negate that expression. 

([a-zA-Z]\w+)[^\w(]

The ^ sign in brackets means that we allow everything besides \w and (.
Hope this helps or points you to another solution.

Best regards, ysf :)

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy