Learning GREP - need help with one example

2013-03-05 Thread Scott
Hi guys, I am fascinated by the GREP capabilities of BBEdit and have been trying to immerse myself in it. I am a complete regex newbie, but I'm starting to understand some of the concepts. However t I need some more practical examples in order to figure it out. Here's my latest problem.

Re: Learning GREP - need help with one example

2013-03-05 Thread John Delacour
On 05/03/2013 04:54, Scott wrote: Let's say I have a URL like this: *http://www.mysite.com/section/subsection/Z3245678a34/* And I want to turn it into an html link with the last element as the highlighted text: *a

Re: Learning GREP - need help with one example

2013-03-05 Thread Christopher Stone
On Mar 04, 2013, at 22:54, Scott scotty...@gmail.com wrote: I am fascinated by the GREP capabilities of BBEdit and have been trying to immerse myself in it. ... Here's my latest problem. Let's say I have a URL like this: http://www.mysite.com/section/subsection/Z3245678a34/ And I

RE: Learning GREP - need help with one example

2013-03-05 Thread Rick Gordon
Title: RE: Learning GREP - need help with one example (https*://\S+/)(\S+?)(/)(?:(?=[ \t\r])|(?=[[:punct:]])|(?=$)) a href=""> Finds http or https May be followed by space, tab, return, punctuation, or end of line (even at end of doc with no return) -- On 3/4/13 at 8:54 PM

RE: Learning GREP - need help with one example

2013-03-05 Thread Rick Gordon
Title: RE: Learning GREP - need help with one example Actually, it would be better to set the last slash to be optional (as below), in case the URL doesn't end in a slash. It would would require a bit more of a tweak to handle query URLs with ?, ., and =., but totally doable:

Re: Learning GREP - need help with one example

2013-03-05 Thread Rick Gordon
Title: Re: Learning GREP - need help with one example That turns your original example (http://www.mysite.com/section/subsection/Z3245678a34/) into: a href="" href="" >Z3245678a34/aa/a is a capture for the whole original _expression_ -- not what you want. I also see that my own suggestion

Re: Learning GREP - need help with one example

2013-03-05 Thread Rick Gordon
Title: Re: Learning GREP - need help with one example Here's my (hopefully) tweaked and corrected version: FIND: (https*://\S+/)(\S+?[^[:punct:]])(/?)(?:(?=[ \t])|(?=[[:punct:]]|$)) CHANGE TO: a href=""> Changes (in bold) include adding [^[:punct:]] at the end of the second capture, so that

Re: Learning GREP - need help with one example

2013-03-05 Thread Rick Gordon
Title: Re: Learning GREP - need help with one example Hey, Chris, You're right. It turned out that I had run it on an already-modified test string. -- On 3/5/13 at 4:24 PM -0600, Christopher Stone wrote in a message entitled Re: Learning GREP - need help with one example:

Re: Learning GREP - need help with one example

2013-03-05 Thread Scott
Rick, Christopher, and eremita, Thank you very much for taking the time to respond. Very helpful! Lots for me to dig into, but I really appreciate the explanations. One quick follow-up. I like the idea of using scripts and textfilters. eremita's script example was perl, I see. I have no

Re: Learning GREP - need help with one example

2013-03-05 Thread Alex Satrapa
On 05/03/2013, at 15:54 , Scott scotty...@gmail.com wrote: I am fascinated by the GREP capabilities of BBEdit and have been trying to immerse myself in it. I am a complete regex newbie, but I'm starting to understand some of the concepts. However t I need some more practical examples in