Re: I believe that SOME non-greedy quantifier(s) SOMEWHERE might help

2018-10-05 Thread F. Alfredo Rego
Hey Chris,

I believe I’m getting closer and closer to appreciating the beauty and the 
simplicity of the concepts behind greedy and non-greedy. 

Patrick’s guidance yesterday worked perfectly and I customized his regex to 
suit my specific needs.

I’ll continue working on simplifying things. Simplicity is VERY powerful.

I hope everyone else in our group will benefit from these conversations.

Thanks for your great tutorial and example.

Alfredo


> On Oct 5, 2018, at 12:38 PM, Christopher Stone  
> wrote:
> 
> On 10/04/2018, at 10:09, F. Alfredo Rego  > wrote:
>> After doing lots of exercises using your example, this greedy vs. non-greedy 
>> challenge WILL be conquered. Once this concept is clear, everything becomes 
>> clear.
> 
> 
> Hey Alfredo,
> 
> Did you wrap your head around the Greedy vs Non-Greedy issue yet?
> 
> It's really very simple in concept.
> 
> First Possible Match vs. Last Possible Match.
> 
> Using this test data:
> 
> 
> 12345678901234567890123456789012345678901234567890
> 
> 
> Greedy:
> 
> 1.+0
> 
> Non-Greedy:
> 
> 1.+?0
> 
> 
> Using this test data:
> 
> 
> /sbin/md5 ~/'test_directory/01_movie_test_file.mov' /sbin/md5 
> ~/'test_directory/02_movie_test_file.mov'
> 
> 
> /sbin/md5 ~/'test_directory/03_movie_test_file.mov'
> 
> 
> Non-Greedy:
> 
> ^\S.+?movie_test_file\.mov
> 
> Greedy:
> 
> ^\S.+movie_test_file\.mov
> 
> 
> Adding other modifiers changes the constraints of what can be found.
> 
> (?s) allows . to match EOL characters and therefore span lines.
> 
> Non-Greedy:
> 
> (?s)^\S.+?movie_test_file\.mov
> 
> Greedy:
> 
> (?s)^\S.+movie_test_file\.mov
> 
> 
> HTH.
> 
> --
> Take Care,
> Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: I believe that SOME non-greedy quantifier(s) SOMEWHERE might help

2018-10-05 Thread Christopher Stone
On 10/04/2018, at 10:09, F. Alfredo Rego mailto:f.alfredor...@gmail.com>> wrote:
> After doing lots of exercises using your example, this greedy vs. non-greedy 
> challenge WILL be conquered. Once this concept is clear, everything becomes 
> clear.


Hey Alfredo,

Did you wrap your head around the Greedy vs Non-Greedy issue yet?

It's really very simple in concept.

First Possible Match vs. Last Possible Match.

Using this test data:


12345678901234567890123456789012345678901234567890


Greedy:

1.+0

Non-Greedy:

1.+?0


Using this test data:


/sbin/md5 ~/'test_directory/01_movie_test_file.mov' /sbin/md5 
~/'test_directory/02_movie_test_file.mov'


/sbin/md5 ~/'test_directory/03_movie_test_file.mov'


Non-Greedy:

^\S.+?movie_test_file\.mov

Greedy:

^\S.+movie_test_file\.mov


Adding other modifiers changes the constraints of what can be found.

(?s) allows . to match EOL characters and therefore span lines.

Non-Greedy:

(?s)^\S.+?movie_test_file\.mov

Greedy:

(?s)^\S.+movie_test_file\.mov


HTH.

--
Take Care,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: I believe that SOME non-greedy quantifier(s) SOMEWHERE might help

2018-10-04 Thread F. Alfredo Rego
Hi Patrick,

This worked like magic.

I’ll have fun “adjusting as necessary” as you mention.

I like the simple beauty of your design, which works perfectly.

After doing lots of exercises using your example, this greedy vs. non-greedy 
challenge WILL be conquered. Once this concept is clear, everything becomes 
clear.


¡Mil gracias! 

Alfredo



> On Oct 4, 2018, at 8:29 AM, Patrick Woolsey  wrote:
> 
> On Oct 04, 2018, at 01:39, F. Alfredo Rego  wrote:
>> 
>> Dear regex gurus,
>> 
>> I have many files that contain text like this and I would like to select 
>> entire blocks for which I have created home-brewed “delimiters” (such as 
>> “Block_begin” and “Block_end”). These delimiters, of course, can be any 
>> metadata that I don’t use as data, so this is just one specific example that 
>> I use for expressions that contain “_debug_”:
>> 
> [...]
> 
> Though it's hard to be sure without testing against actual data :-), I 
> suggest you try this:
> 
> Find:   {.+?Block_begin(?s).+?Block_end
> 
> and adjust if need be.
> 
> This pattern starts by matching a literal left curly bracket { followed by 
> one or more instances of any character .+ _non-greedily_ ? up to the literal 
> string "Block_begin", then uses the modifier (?s) to allow . to match line 
> breaks and again performs a _non-greedy_ search for one or more instances of 
> any character .+? -- this time across line breaks if necessary -- until it 
> matches the literal string "Block_end" and that's all, folks. ;-)
> 
> 
> Regards,
> 
> Patrick Woolsey
> ==
> Bare Bones Software, Inc. 

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.