Home / Apple / On Getting Started With Regular Expressions
the curious case of adware doctor and the mac app store 660x330 - On Getting Started With Regular Expressions

On Getting Started With Regular Expressions

On Getting Started With Regular Expressions

Dr. Drang, relating to Jason Snell’s story of the usage of BBEdit and Excel to create a running RSS feed for an outdated podcast, “Don’t Fear the Regex”:

Although I do steadily write brief systems for textual content munging, I
most often lodge to that provided that the issue calls for greater than
simply large-scale textual content modifying or if I be expecting to be repeating the
procedure a number of instances. And even then, I most often get started out by means of
taking part in round in BBEdit to peer what searches, replacements, and
rearrangements want to be executed. It’s a handy atmosphere for
getting rapid comments on every transformation step.

(And if you are expecting to do a chain of textual content transformations steadily
and truly don’t wish to get into writing scripts in Perl or
Python or Ruby or no matter, BBEdit’s Text Factories will let you
string in combination any collection of person munging steps.)

After I related to Snell’s piece, a reader emailed to invite why I didn’t assume this may’ve been higher solved by means of writing a script in Perl/Python/Ruby or every other language with excellent regex fortify. Why use Excel for date transformations when scripting languages all have intensive date libraries?

What Drang describes above is my procedure too. If the duty to hand is one thing I handiest want to do a few times, at this time, it’s merely more uncomplicated to simply do it in BBEdit. I’m handiest going to make a correct script if it’s one thing I do know or suspect I’ll reuse. But even if I do write a script to automate some type of textual content munging, it inevitably begins with me figuring out the regex transformations step by step in BBEdit. Instant visible comments with undo fortify — I’ve labored with textual content this fashion since 1992.


Even worse, people who find themselves pondering they must get started the usage of
common expressions steadily listen about this nice guide at the
subject and feature a herbal response once they see it: A 500+ web page
guide to discover ways to seek for textual content? No thank you.

This is just too unhealthy, as a result of whilst Friedl’s guide is superb, it’s referred to as
Mastering Regular Expressions for a reason why, and that reason why isn’t
as it’s an educational. My advice for an educational is the
one I discovered from over 20 years in the past: the “Searching with Grep”
bankruptcy within the BBEdit User Manual. I imagine it was once in large part
written by means of a tender man named John Gruber.

As for the Grep bankruptcy in BBEdit’s consumer handbook — I did write a vital a part of it, however I will’t take and shouldn’t get credit score for it all. Long tale brief, till BBEdit 6.five, BBEdit used a quite elementary regex engine. If I recall as it should be, it was once a extremely custom designed model of Henry Spencer’s vintage library, which supported handiest the vintage options of normal expression syntax. I driven for BBEdit to change to Philip Hazel’s superb PCRE (Perl Compatible Regular Expressions) library, which helps almost about each and every complex little bit of regex syntax any individual may just need — and it’s rapid, helps Unicode, written in excellent blank cross-platform C, and extra.

The Grep bankruptcy in BBEdit’s consumer handbook was once already superb once I got to work at Bare Bones — all of the handbook, cover-to-cover, has all the time been and stays essentially superb. In reality, like Drang, I discovered common expressions by means of studying BBEdit’s Grep bankruptcy. I went from “this stuff looks like gibberish” to “Oh, I get it, I see how this could be super useful” simply by studying that bankruptcy. If you’re regex-curious, I extremely suggest that you simply get started by means of studying that bankruptcy — even though you’re now not a BBEdit consumer. The regex syntax it describes will paintings in almost about each and every present programming language or textual content editor. (The handbook is to be had in BBEdit’s Help menu.)

What I contributed to the Grep bankruptcy was once the entire stuff in PCRE that BBEdit’s outdated regex engine didn’t fortify, which, admittedly, is a lot of stuff. Prompted by means of Drang’s sort phrases, I simply re-read the bankruptcy for the primary time in a couple of years, and it holds up. And I’m lovely certain the road about what number of licks it takes to get to the middle of a Tootsie Pop was once mine.1

Check Also

u s regulators have met to discuss imposing a record setting fine against facebook for privacy violations 310x165 - U.S. regulators have met to discuss imposing a record-setting fine against Facebook for privacy violations

U.S. regulators have met to discuss imposing a record-setting fine against Facebook for privacy violations

U.S. regulators have met to discuss imposing a record-setting fine against Facebook for privacy violations …

Leave a Reply

Your email address will not be published. Required fields are marked *