dcsimg
Results 1 to 11 of 11

Thread: Ever wanted some theory behind regular expressions ?

  1. #1

    Thread Starter
    Fanatic Member BlindSniper's Avatar
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    865

    Ever wanted some theory behind regular expressions ?

    Hi all,
    Being a self taught programmer I taught myself regular expressions just by analyzing examples I found on the internet. Recently though I was watching a Coursera course that Stanford did about compilers and they did a few videos that were related to regular expressions, and I thought they explained regular expressions brilliantly.

    https://class.coursera.org/compilers.../lecture/index

    watch videos 03-03 to 03-05. (you will probably have to register to see those videos)
    the first two videos will not be very clear as to what is going on but listen to what the guy is saying and try to remember it. All will become clear in the third video. Also keep in mind that the context of these videos is about compilers.

    I feel like I now actually understand regular expressions and I probably am a better programmer because of it. I now also know that regular expressions wasn't just some sadistic trick someone played on programmers.

    Useful CodeBank Entries of mine
    Expand Function
    Code Compiler
    Sudoku Solver
    HotKeyHandler Class

    Read this to get Effective help on VBForums
    Hitchhiker's Guide to Getting Help at VBF

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,416

    Re: Ever wanted some theory behind regular expressions ?

    Please don't use them in a production environment at a site where only you made a study of them. They are a language in themselves and in my opinion whatever you gain in performance or succinct code will be lost when someone else needs to support them. I've been in programming a long time, and others may disagree, but I stand by the KISS programming philosophy...Keep It Simple Stupid.

    I've never worked on any high volume, high performance systems and maybe a few nanoseconds really makes a difference. Being in small companies with a user base in the hundreds on our own servers I feel it is safe to not use them. Personally I think the world would be better off without them.

    I understand they are great to have in your tool kit. Just do your average production support programmers a favor and don't use them.

    This quote is from Jamie Zawinski, a world class hacker...

    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    Last edited by TysonLPrice; Mar 27th, 2013 at 06:07 AM.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,723

    Re: Ever wanted some theory behind regular expressions ?

    I have a regular expression I use when confronted by certain types of problems. It is something like this: @(#*$&)$) @#*&$#!!!
    My usual boring signature: Nothing

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,922

    Re: Ever wanted some theory behind regular expressions ?

    i wonder if anyone has ever done a study to see how much time and money has been lost due to subtle errors in regular expressions that only crop up erratically...

    Suddenly the bank has transferred $10,000 from your account instead of $100.

    Investigation can't find a cause so the bank just hires two people to take complaints and correct the transactions manually for the next decade.

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,867

    Re: Ever wanted some theory behind regular expressions ?

    When the bank code was in cobol they never had problems like this...

    The original reg exp was added sometime after the code was outsourced...

    Then those two people hired to take complaints...

    ...also outsourced...

    I see a pattern here - can a reg exp describe that?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,416

    Re: Ever wanted some theory behind regular expressions ?

    I was looking for some humor regarding regular expressions. Nothing showed up which doesn't surprise me at at all. I did see these though:

    “The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.”
    – Tom Cargill

    “In order to understand recursion, one must first understand recursion.”
    – Author Unknown

    “I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.”
    – Bjarne Stroustrup

    “A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila.”
    – Mitch Ratcliffe

    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”
    -C.A.R. Hoare

    “The gap between theory and practice is not as wide in theory as it is in practice.”
    – Author Unknown

    “If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.”
    – Gerald Weinberg

    “If debugging is the process of removing software bugs, then programming must be the process of putting them in.”
    – Edsger Dijkstra

    “Measuring programming progress by lines of code is like measuring aircraft building progress by weight.”
    – Bill Gates

    “Nine people can’t make a baby in a month.”
    – Fred Brooks

    “Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.”
    – Rich Cook

    “There are two major products that come out of Berkeley: LSD and UNIX. We don’t believe this to be a coincidence.”
    – Jeremy S. Anderson

    “Before software can be reusable it first has to be usable.”
    – Ralph Johnson

  7. #7
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,105

    Re: Ever wanted some theory behind regular expressions ?

    A great collection of quotes, Tyson. There's only one that makes me wonder:

    “Nine people can’t make a baby in a month.”
    – Fred Brooks
    Shouldn't that be 18 people? And perhaps they can, given the law of averages. Besides it would be one heck of a party!

    BB

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,733

    Re: Ever wanted some theory behind regular expressions ?

    Name:  rockRegEx.jpg
Views: 52
Size:  31.4 KB
    I'll just leave this here...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,922

    Re: Ever wanted some theory behind regular expressions ?

    4th frame should show the fiery crash.

  10. #10
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Ever wanted some theory behind regular expressions ?

    I agree with BB .. great stuff, Tyson.

    Spoo

  11. #11
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,219

    Re: Ever wanted some theory behind regular expressions ?

    Regexes are powerful tools that can go out of control very quickly. Catastrophic Backtracking can occur before you know it.

    I like to compare them with using an out of control chain-saw that cut off an entire forest, when all you originally intended was trim a few branches. There are people who can code using regular expressions and people who cannot. There's an explanation for Jamie's quote on this blog.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width