Now for a quick break along the lines of “Obvious in retrospect: Duh”.

I knew exactly what I wanted, to find the needle(s) in a VERY large stack 
(thousands upon thousands of lines of code).

However, I was sidetracked from simplicity by the siren songs of sophisticated 
technology (fabulous ways of finding what I DIDN’T want — both backwards and 
forwards — and then negating/reversing/inverting to get what I wanted). 

In the process, I missed the (now obvious) simplest solution, as expressed by 
Dave: Match at the start for zero or more horizontal spaces (“\s” also works as 
a generic space) followed by #define

^\h*#define

or

^\s*#define


This got exactly what I wanted: All defined #defines regardless of indentation.

Fortunately, this little excursion into new and wild territories (at least for 
me) pointed the way to further research and learning.


With deep appreciation,

Alfredo


> On Apr 16, 2018, at 8:28 AM, Jean-Christophe Helary 
> <[email protected]> wrote:
> 
> Thank you for asking the question in the first place. It was my first time 
> putting such devices into action, I really got interested in them !
> 
> JC
> 
>> On Apr 16, 2018, at 23:15, F. Alfredo Rego <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Jean-Christophe, Dave, Chris,
>> 
>> Great suggestions.
>> 
>> What Chris suggested worked on all cases, indented or not:
>> ^(?>(?:(?!//).)*#define.+)
>> 
>> What Dave suggested worked on all cases, indented or not:
>> ^\h*#define
>> 
>> What Jean-Christophe suggested (with that tricky space configured precisely) 
>> worked on #defines without leading spaces but it also found an indented 
>> COMMENTED #define:
>> 
>> Original test case:
>> 
>> <BBEdit_030.png>
>> 
>> 
>> <BBEdit_032.png>
>> 
>> <BBEdit_033.png>
>> 
>> 
>> 
>> 
>> 
>> The simplest was Dave’s suggestion.
>> 
>> What Chris and Jean-Christophe suggested motivated me to dive deeper into 
>> positional assertions (with their various flavors and caveats), as Chris 
>> mentioned:
>> 
>> Positional assertions are great, but why use them if you don’t have to, 
>> especially look-behinds, which can’t have variable string lengths?
>> 
>> So much to learn!
>> 
>> 
>> With many thanks to the three of you,
>> 
>> Alfredo
>> 
>> 
>> 
>> On Apr 16, 2018, at 7:09 AM, Christopher Stone <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> On 04/16/2018, at 01:59, F. Alfredo Rego <[email protected] 
>> <mailto:[email protected]>> wrote:
>>> I’m almost there, but not quite, because I’m interested in the UNCOMMENTED 
>>> #defines, such as line 5 here:
>> 
>> 
>> Hey Alfredo,
>> 
>> What you really want here is a negative lookahead assertion.
>> 
>> ^(?>(?:(?!//).)*#define.+)
>> 
>> It's much more flexible than a negative lookbehind assertion, although it 
>> can be a bit hard to understand.
>> 
>> --
>> Best Regards,
>> Chris
>> 
>> 
>> 
>> 
>> On Apr 16, 2018, at 5:44 AM, Dave <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> How about 
>> ^#define
>> or, if some might be indented,
>> ^\h*#define
>> 
>> Positional assertions are great, but why use them if you don't have to, 
>> especially look-behinds, which can't have variable string lengths?
>> 
>> 
>> 
>> 
>> 
>> On Apr 16, 2018, at 3:48 AM, Jean-Christophe Helary 
>> <[email protected] <mailto:[email protected]>> 
>> wrote:
>> 
>> 
>> On my side I get the uncommented lines.
>> 
>> (?<!// )#define
>> 
>> <Screen Shot 2018-04-16 at 18.48.00.png>
>> 
>> JC
>> 
>> 
>> -- 
>> This is the BBEdit Talk public discussion group. If you have a 
>> feature request or would like to report a problem, please email
>> "[email protected] <mailto:[email protected]>" rather than posting 
>> to the group.
>> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit 
>> <http://www.twitter.com/bbedit>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at https://groups.google.com/group/bbedit 
>> <https://groups.google.com/group/bbedit>.
> 
> Jean-Christophe Helary
> -----------------------------------------------
> http://mac4translators.blogspot.com <http://mac4translators.blogspot.com/> 
> @brandelune
> 
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, please email
> "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit 
> <http://www.twitter.com/bbedit>>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/bbedit 
> <https://groups.google.com/group/bbedit>.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to