Re: Another Newbie GREP help request...

2018-05-19 Thread Christopher Stone
On 05/14/2018, at 22:15, Matthew London > wrote:
> PS.Grateful if someone can recommend a "GREP for non-programmers" written in 
> plain(er) English so I don't have to bother you very helpful people here.


Hey Matthew,

It takes a while to get good enough with regular expressions to manage anything 
but the basics without a hint or two, but don't let that worry you – Practice 
makes Progress.

It's been awhile, since I updated this – but all the links are current.

--
Best Regards,
Chris

---
Some Information on Learning Regular Expressions – by Christopher C. Stone
---

Learning basic regular expressions is relatively easy.  Becoming really good 
with them takes dedication, a lot of practice, and some tutelage.

The BBEdit Manual devotes a whole chapter to regular expressions: Searching 
with Grep (currently chapter 8).  It's a reference rather than a tutorial, but 
it does explain at least briefly many of the fundamentals.

My cheat-sheet for BBEdit is up on Gist:

https://gist.github.com/ccstone/5385334 


BBEdit uses PCRE (Perl Compatible Regular Expressions), so it's a pretty decent 
if not complete reference.

Regex neophytes are better off starting with a book specifically written for 
beginners.

I have these books (in addition to a couple of tomes on Perl):

"Sams Teach Yourself Regular Expressions in 10 Minutes" by Ben Forta
"Beginning Regular Expressions" by Andrew Watt
"Regular Expressions Cookbook"  by Jan Goyvaerts and Steven Levithan
"Mastering Regular Expressions" by Jeffrey Friedl (Advanced)

There's a decent little utility available on the App-Store called 'Patterns' 
that live-updates as you create your pattern. ($2.99)

https://itunes.apple.com/us/app/patterns-the-regex-app/id429449079?mt=12 


I've found it very handy to have live feedback when building a complex pattern 
and wish I'd had something like that when I started learning regex more than 20 
years ago.

Extracting a good working knowledge of regular expressions from the Internet is 
a serious chore.  There are many flavors of regex out there, such as Perl/PCRE, 
Java, Javascript, Ruby, Python, TCL...  They're all similar, but the 
differences can be very confusing and frustrating.

Nevertheless there are many useful online resources.  Here are a few:

http://www.agillo.net/regex-primer-part-1/ 

http://www.agillo.net/regex-primer-part-2/ 

http://www.codeproject.com/KB/dotnet/regextutorial.aspx 

http://www.regular-expressions.info/tutorial.html 


---
Tags: @Learning, @Regular, @Expressions, @Regular_Expressions, @RegEx, @GREP, 
@Info
---


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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: Another Newbie GREP help request...

2018-05-18 Thread Matthew London
I think I see my problem.
I was using "Process Lines Containing" which appears to extract the entire 
line, not matter what I search for.
I used Search with the Extract function, and it works now! 

Thank you


On Friday, May 18, 2018 at 1:47:33 AM UTC-7, Rick Gordon wrote:
>
> Change the .* in your string to [^.]* 
>
> (And you don't need the square brackets around \. ) 
>
> So: 
> from [A-Z][a-zA-Z][^.]*\. 
>
> …which really means: 
>
>  from followed by a space 
>
>  a single capital letter, not including diacriticals/accents 
>
>  a single letter of any case, not including diacriticals/accents 
>
>  any number (including zero) of non-period characters (which may 
> include other punctuation, spaces, line breaks, etc.) 
>
>  a period 
>
> Does that work, or do you need to be more specific? 
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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: Another Newbie GREP help request...

2018-05-18 Thread Rick Gordon

Change the .* in your string to [^.]*

(And you don't need the square brackets around \. )

So:
from [A-Z][a-zA-Z][^.]*\.

…which really means:

from followed by a space

a single capital letter, not including diacriticals/accents

a single letter of any case, not including diacriticals/accents

any number (including zero) of non-period characters (which may 
include other punctuation, spaces, line breaks, etc.)


a period

Does that work, or do you need to be more specific?

Rick Gordon


On May 18, 2018 at 1:33:08 AM [-0700],
Matthew London wrote in an email entitled
"Re: Another Newbie GREP help request...":
I managed to figure out that the following would give me everything 
that had "from" followed by a capital letter, with a period followed 
by a space at the end:


from [A-Z][a-zA-Z].*[\. ]

But that also gives me all the sentences in the line which 
preceded the one I need!


How would I strip out all the sentences that precede the one I need?

___
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___
WWW: http://www.shelterpub.com

--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

"supp...@barebones.com" 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 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: Another Newbie GREP help request...

2018-05-15 Thread Patrick Woolsey

Please try this:

from [A-Z][a-zA-Z]+

with both the "Case sensitive" and "Grep" options enabled.

In summary, "from " will match these literal characters, while 
the first _character class_ [A-Z] will match a single capital 
letter, and the second _character class_ [a-zA-Z] modified by + 
will match 'at least one or more' capital and/or lowercase letters.


(NB: You may wish to fine-tune this pattern depending on what 
you want a "word" to consist of. :-)


As to grep references, I suggest you start with Chapter 8 
"Searching with Grep" of the included PDF manual (available at 
any time via Help -> User Manual) and work from there.



Regards,

 Patrick Woolsey
==
Bare Bones Software, Inc. 




On 5/14/18 at 11:15 PM, mlon...@gmail.com (Matthew London) wrote:


Hi,
Struggling to get my head around GREP...

I need to use Process Lines Containing function in BBEdit to 
find all lines that  contain the word "from" followed by a 
space, followed by any word that begins with a capital letter


ie:   He is from California
but not
He is from his mother


PS.Grateful if someone can recommend a "GREP for 
non-programmers" written in plain(er) English so I dont have to 
bother you very helpful people here.

Thanks :-)



--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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: Another Newbie GREP help request...

2018-05-15 Thread 'Holger Bartel' via BBEdit Talk
Hi, 

if I’m not mistaken you could use either

from [A-Z]+

Or 

from [[:upper:]]+

Not on a computer right now, so this is untested, but hopefully is correct and 
helps ;) 

As for books, maybe one of the O’Reilly pocket references, but I’m not sure 
about the plainer english…

Best,
Holger


> On 15 May 2018, at 5:15 AM, Matthew London  wrote:
> 
> Hi,
> Struggling to get my head around GREP...
> 
> I need to use Process Lines Containing function in BBEdit to find all lines 
> that  contain the word "from" followed by a space, followed by any word that 
> begins with a capital letter
> 
> ie:   
> He is from California
> but not
> He is from his mother
> 
> 
> PS.Grateful if someone can recommend a "GREP for non-programmers" written in 
> plain(er) English so I dont have to bother you very helpful people here.
> Thanks :-)
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, 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.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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.