[TUHS] Regular Expressions

Earl Baugh earl.baugh at gmail.com
Sat Aug 1 14:31:00 AEST 2020


I have a 30k+ character regex that I used to parse US street addresses from a single line of input into component pieces. That’s the largest ( and yes it was crazy... but it just grew and grew...and made sense to me as I decomposed the problem ).   That’s the largest one I ever saw.... and it was the fastest way I could solve the problem.. both mentally and processing wise.  

( there was some post processing to deal with soundex matching and data base matching of the pieces to confirm the right answer.  But it solved the problem with 95%+ accuracy... that I got into the high 99%’s with the post processing. )

So that’s at least an example of an arbitrary problem that was solved with regex. 

Earl 


Sent from my iPhone

> On Jul 31, 2020, at 11:08 PM, Will Senn <will.senn at gmail.com> wrote:
> 
> 
> Oh, and one good google over another, I also found this:
> 
> https://www.drdobbs.com/architecture-and-design/regular-expressions/184410904
> 
> Which is also great and simple to follow :).
> 
> Will
> 
>> On 7/31/20 7:36 PM, Rob Pike wrote:
>> I think this link -  https://swtch.com/~rsc/regexp/regexp1.html i- s the best place to start. Superb exposition on the background, theory, and implementation as well as a bit of history of how the industry lost its way with regular expressions.
>> 
>> Regular expressions are beautiful, simple, and widely misunderstood.
>> 
>> -rob
>> 
>> 
>> On Sat, Aug 1, 2020 at 10:03 AM Bakul Shah <bakul at iitbombay.org> wrote:
>>> On Jul 31, 2020, at 3:57 PM, Will Senn <will.senn at gmail.com> wrote:
>>> > 
>>> > I've always been intrigued with regexes. When I was first exposed to them, I was mystified and lost in the greediness of matches. Now, I use them regularly, but still have trouble using them. I think it is because I don't really understand how they work.
>>> > ...
>>> > 1. What's the provenance of regex in unix (when did it appear, in what form, etc)?
>>> > 2. What are the 'best' implementations throughout unix (keep it pre 1980s)?
>>> > 3. What are some of the milestones along the way (major changes, forks, disagreements)?
>>> > 4. Where, in the source, or in a paper, would you point someone to wanting to better understand the mechanics of regex?
>>> 
>>> Start here: https://en.wikipedia.org/wiki/Thompson%27s_construction
>>> 
>>> [I learned about regular expressions in an automata theory class, 
>>>  before I knew anything about Unix. What helped me was learning
>>>  about finite state machines. You won't need more than paper and
>>>  pencil to construct one. Reading source code would make more
>>>  sense once you grasp how to construct a FSM corresponding to a RE.]
> 
> 
> -- 
> GPG Fingerprint: 68F4 B3BD 1730 555A 4462  7D45 3EAA 5B6D A982 BAAF
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20200801/aa779ba9/attachment.htm>


More information about the TUHS mailing list