Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Regex advice needed - C language
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shreyas  
View profile  
 More options Oct 14, 11:28 pm
From: Shreyas <shreyasbhar...@gmail.com>
Date: Wed, 14 Oct 2009 20:28:08 -0700 (PDT)
Local: Wed, Oct 14 2009 11:28 pm
Subject: Regex advice needed - C language
How do I construct a regex that finds just the first instance in the
following test sample -

#define LOGGING_ENABLED
//#define LOGGING_ENABLED
// #define LOGGING_ENABLED
/* #define LOGGING_ENABLED */
/*#define LOGGING_ENABLED*/

i.e. the result should be #define LOGGING_ENABLED. As you can see I am
trying to find instances of the #define which are not commented out.

I'd appreciate any help.

- Shreyas.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eugeny.Sattler@gmail.com  
View profile  
 More options Oct 16, 2:45 am
From: "Eugeny.Satt...@gmail.com" <eugeny.satt...@gmail.com>
Date: Thu, 15 Oct 2009 23:45:51 -0700 (PDT)
Local: Fri, Oct 16 2009 2:45 am
Subject: Re: Regex advice needed - C language
try this

[\r\n]+\s*\#define\x20+LOGGING_ENABLED\s*[\r\n]+

that is line break(s) followed by optional space(s) followed by
"#define LOGGING_ENABLED" followed bt optional space(s) followed by
linebreak(s)

while this enhancement should fit for start of file and end of file
locations, as well.

(\A|[\r\n]+)\s*\#define\x20+LOGGING_ENABLED\s*([\r\n]+|\Z)

excerpt from help:
--------------------
\A only ever matches at the start of the string. Likewise, \Z only
ever matches at the end of the string. These two tokens never match at
line breaks. This is true in all regex flavors discussed in this
tutorial, even when you turn on "multiline mode". In EditPad Pro and
PowerGREP, where the caret and dollar always match at the start and
end of lines, \A and \Z only match at the start and the end of the
entire file.

JavaScript, POSIX and XML do not support \A and \Z. Use the caret and
dollar for this purpose.

On 15 October, 08:28, Shreyas <shreyasbhar...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shreyas  
View profile  
 More options Oct 20, 6:39 pm
From: Shreyas <shreyasbhar...@gmail.com>
Date: Tue, 20 Oct 2009 15:39:35 -0700 (PDT)
Local: Tues, Oct 20 2009 6:39 pm
Subject: Re: Regex advice needed - C language
Thank you, that worked like a charm!

Note to self -
Learn RegEx properly! :D

On Oct 16, 7:45 pm, "Eugeny.Satt...@gmail.com"


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google