Re: Find & Replace - New Line

42 views
Skip to first unread message

Christopher Stone

unread,
May 14, 2013, 3:37:07 PM5/14/13
to textwr...@googlegroups.com
On May 14, 2013, at 08:41, Seth Calkins <seth.ca...@gmail.com> wrote:
I'm trying to do a find and replace to match whole sentences which may, or may not be on multiple lines.

Needs to match all of the following, ignoring new line

Example:

Telephone Automatic Answering
Equip & Systems

or

Telephone Automatic Answering Equip & Systems
______________________________________________________________________

Hey Seth,

This is a real problem unless your sentences are demarcated by punctuation or whitespace.  Can you provide a more complete example?  One that shows more of the document structure?

If paragraphs are separated by a couple of returns or linefeeds you can do something like:

(?sm)^\w+.+?(?=\r{2,})

But more info please.

Does anyone have any suggestions for some additional tools, to learn GREP other than, the Text Wrangler tutorial? I'm having difficulty figuring all of this out.

Learning grep is a lifetime enterprise, so don't feel bad about the bumpy road.  The basics are relatively easy, but becoming an advanced player requires time, dedication, a lot of practice, and some tutelage.

I put my cheat-sheet for BBEdit up on Gist, but it should work with TextWrangler.

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

Here are a few useful online resources:


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


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 20+ years ago.

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)

--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages