Slashdot Mirror


Regular Expression Recipes

r3lody writes "If you spend time working writing applications that have to do pattern matches and/or replacements, you know about some of the intricacies of regular expressions. For many people they can be an arcane hodgepodge of odd characters that somehow manage to do wonderful things, but they don't have enough time (or interest) to really understand how to code them. Nathan A. Good has written Regular Expression Recipes: A Problem-Solution Approach for those people. In its relatively slim 289 pages, he offers 100 regular expressions in a cookbook format, tailored to solve problems in one of six broad categories (Words and Text, URLs and Paths, CSV and Tab-Delimited Files, Formatting and Validating, HTML and XML, and Coding and Using Commands)." Read on for the rest of Lodato's review. Regular Expression Recipes: A Problem-Solution Approach author Nathan A. Good pages 289 publisher Apress rating 8/10 reviewer Raymond Lodato (rlodato AT yahoo DOT com) ISBN 159059441X summary A cookbook of useful regular expressions for Perl, Python and more.

Regular expressions are not restricted to just the Perl or shell environments, so Nathan offers variations for Python, PHP, and VIM as well. In most cases the translation is relatively straight-forward, but in a few cases a different environment may have (or lack) additional facilities, prompting a different expression to do the same task.

Before you even read chapter 1, Nathan provides a quick summary course on regular expressions, with detail given to each of the five environments you might utilize. He has written the syntax overview in a highly-readable format, making it easy to understand the gobbledy-gook of the most bizarre concoctions you might encounter.

The first chapter (Words and Text) starts simply enough. He gives examples of how to find single words, multiple words, and repeated words, along with examples of how to replace various detected strings with others. In each case he gives an example of its use for each platform, followed by a bit-by-bit breakdown of how it works. Not every environment is given on every example, and in many cases the "How It Works" section refers to the first one, as most REs are identical between the platforms.

The next chapter (URLs and Paths) offers various methods of doing commonly needed parsing. Pulling out file names, query strings, and directories, as well as reconstructing them in useful fashions is covered in the 15 offerings given here. Validating, converting, and extracting fields of CSV and tab-delimited files are handled in chapter 3, while chapter 4 is concerned with validating field formats, as well as re-formatting text for the fields. Chapter 5 handles similar tasks for HTML and XML documents. The final chapter covers expressions that facilitate the management of program code, log files, and the output of selected commands.

First, I must admit that there are a number of useful solutions provided, especially for someone who is concerned with application and web development. However, I did feel a little cheated by the fact that several chapters covered essentially the same task, with only minor variations. It almost seemed as though the author was trying to pad out the solution count to the magic number 100. A simple example: three solutions in chapter one cover (a) replacing smart quotes with straight quotes, (b) replacing copyright symbols with the (c) tri-graph, and (c) replacing trademark symbols with the (tm) sequence. In each case, the expression was simply "s/\xhh/ rep /g;". Did we really need three separate chapters for that? I don't think so.

Another quibble revolves around some of the coding of the expressions. Nathan has made liberal use of the non-capturing groups (that is, (: expr )) to insure only the items that needed replacement were captured. While a worthy idea, in some cases the expression may have been simplified for understanding. Another issue is a slight error in searching for letters. In a number of expressions, Nathan uses [A-z] to capture all letters. Unfortunately, the special characters [, \, ], ^, _, and ` occur between upper-case Z and lower-case a, making it match too much. Either [[:alpha:]] or [A-Za-z] should have been used.

Despite these quibbles, Regular Expression Recipes does provide a useful compendium of solutions for common problems developers face. Presenting the information in a cookbook fashion, along with ensuring that those using something other than Perl don't have to sweat translating the expressions to their target language, makes this a handy book to have. I wouldn't hesitate to recommend it.

You can purchase Regular Expression Recipes: A Problem-Solution Approach from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

59 of 258 comments (clear)

  1. Curious by LiquidCoooled · · Score: 3, Funny

    I was performing a strange custom regular expression on the book review, and discovered that it outputted the following:

    "Regex coders are in league with the devil"

    Who woulda thunk it!

    --
    liqbase :: faster than paper
    1. Re:Curious by Saeed+al-Sahaf · · Score: 4, Funny
      interesting, so what secret regular expression construct matches what is nowhere in the original string?

      It's something called a joke. A joke is something said or done to evoke laughter or amusement, especially an amusing story with a punch line. Jokes employ something called humor. Humor is the quality that makes something laughable or amusing. Many Slashdotters are unable to perceive, enjoy, or express what is amusing, comical, incongruous, or absurd, often referred to as humor impaired.

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    2. Re:Curious by ErikZ · · Score: 2, Funny

      You're pretty touchy for a mechanical abomination, devoid of all life and only a mere shadow of the men you were bult to replace.

      You should try tweaking your .conf.

      --
      Democrats or Republicans. They are both taking us to the same place and they are not afraid of us anymore.
  2. Points by 2.7182 · · Score: 4, Informative

    I really liked this book, but

    1. the binding broke
    2. the index has a lot of typos.

    1. Re:Points by LiquidCoooled · · Score: 2, Funny

      2. the index has a lot of typos.

      No problem, the website issued a global regex and a pot of tip-ex for all customers.

      --
      liqbase :: faster than paper
    2. Re:Points by poot_rootbeer · · Score: 2, Funny

      2. the index has a lot of typos.

      Yeah, but in a book about regexes, you have to study the index VERY CAREFULLY to determine whether there are any typos or not.

  3. Bran... by Anonymous Coward · · Score: 3, Funny

    ...is the best regular recipe.

  4. Another one? by cmstremi · · Score: 2, Insightful

    Isn't there already enough coverage for Regex's? With all the existing books and the nearly endless availability of free information and sites (including many using the 'recipie' format) online, who will want this book.

    1. Re:Another one? by carnivore302 · · Score: 3, Informative

      I don't think there is a need for another book on regexps, since there is already the excellent Mastering Regular Expressions by Jeffrey Friedl. What else then the best can you expect from an O'Reilly book?

      --
      Please login to access my lawn
  5. Regular expressions in a cookbook? by DeadSea · · Score: 5, Informative

    Sounds like good eating. ;-)

    Regular expressions are great, but once you know them and you think you can conquer the world, I find they occasionally let you down. The text editor I was using had a rudementary regular expression search that did not support non-greedy matching. I found that writing a regular expression that finds C style /* comments */ to be quite tricky with only greeding matching. I wrote it up as an article where I build the expression piece by piece showing common things you might try that won't work.

    If you want more of a challenge, try writing a regular expression that find any <script></script> tags along with anything in between using only greedy matching. You will find that the length of your regular expression goes up exponentially with the length of your ending condition.

    --
    Calculator for Converting Currency

    1. Re:Regular expressions in a cookbook? by interiot · · Score: 4, Interesting
      Yup, regular expressions are not capable of a full-range of computing... they're pretty close (they're the lowest of four in the Chomsky hierarchy), but still have a few limitations that can't be resolved without wrapping some extra code around them.

      It still boggles my mind that people knew this in 1956 though.

    2. Re:Regular expressions in a cookbook? by merlyn · · Score: 5, Informative
      Yup, regular expressions are not capable of a full-range of computing
      That's the "classic" regular expressions, not the modern regular expressions accepted by PCRE, and Perl itself. In fact, Perl regular expressions are full Turing machines, with PCRE being a few steps behind that. So PCRE isn't really PCRE... it's P-likeCRE. {grin}
    3. Re:Regular expressions in a cookbook? by pcraven · · Score: 2, Interesting

      This is a cool article on catastrophic backtracking. I remember the first time that got me. It would occasionally cause severe issues on a production server we had. I swung and missed with my reg ex on that one.

    4. Re:Regular expressions in a cookbook? by interiot · · Score: 3, Insightful
      You mean all the sections of the perl regexp manual that say "WARNING: This extended regular expression feature is considered highly experimental, and may be changed or deleted without notice" and then go on to say things that make my head truly ache?

      I personally treat this like I do Perl5 threads... as something to be afraid of, and hopeful that things will be much improved in Perl 6.

    5. Re:Regular expressions in a cookbook? by DeadSea · · Score: 2, Informative

      Your expression fails for this case:

      <script><scri</script>

      It will match <scri< with your |</scri[^p] rule and then go on to match beyond the end of your regular expression.

      But I acknowledge that it may be quadratic rather than exponenetial even with a correct regular expression.

      --
      Exchange Rate Calculator

    6. Re:Regular expressions in a cookbook? by prockcore · · Score: 2, Interesting

      I've been doing regex for a long time (over 10 years), and the best rule I can give newbies to follow is "match less, not more"

      Write your regex's so that they generalize as little as possible.

      For example, matching an xml tag use /]+>/ instead of //

      If you're using ".*?" in a regex, you might want to look at rewriting it.. it's almost never needed and almost always causes problems.

    7. Re:Regular expressions in a cookbook? by prockcore · · Score: 2, Interesting

      (damn, I should really preview sometimes)

      The examples I gave are: /<[^>]+>/ instead of /<.*?>/

  6. REGEX by null+etc. · · Score: 5, Funny
    Another quibble revolves around some of the coding of the expressions. Nathan has made liberal use of the non-capturing groups (that is, (: expr )) to insure only the items that needed replacement were captured. While a worthy idea, in some cases the expression may have been simplified for understanding.

    I'm not sure I understand what your quibble is - do you dislike the fact that he uses non-capturing groups, or the fact that he disposes of them at certain points?

    Another issue is a slight error in searching for letters. In a number of expressions, Nathan uses [A-z] to capture all letters. Unfortunately, the special characters [, \, ], ^, _, and ` occur between upper-case Z and lower-case a, making it match too much. Either [[:alpha:]] or [A-Za-z] should have been used.

    This seems like a relatively novice mistake, and I'm surprised it would show up in a book on regular expressions.

    Despite these quibbles, Regular Expression Recipes does provide a useful compendium of solutions for common problems developers face. Presenting the information in a cookbook fashion, along with ensuring that those using something other than Perl don't have to sweat translating the expressions to their target language, makes this a handy book to have. I wouldn't hesitate to recommend it.

    It's nice that he covers five environments for regular expressions. I'm sure everyone has heard of Mastering Regular Expressions, published by O'Reilly. The Perl Cookbook also does a good job at solving common problems with Regular expressions.

    This is just my opinion, but I think what the world needs is a book on Regular Expression Design Patterns.

  7. Unacceptable mistakes by gniv · · Score: 5, Interesting
    In a number of expressions, Nathan uses [A-z] to capture all letters.

    How can this be a good book when it makes such mistakes? If this book is for beginners (as it seems) the editing process should have been much better.

    1. Re:Unacceptable mistakes by tehshen · · Score: 2, Insightful

      [A-z] accepts all characters from A to z, including [ \ ] ^ _ and `. You want [A-Za-z] or \w (latter for 'not punctuation').

      --
      Guy asked me for a quarter for a cup of coffee. So I bit him.
    2. Re:Unacceptable mistakes by hattmoward · · Score: 2, Informative

      \w is [A-Za-z0-9_]. The reviewer mentions use of the POSIX character class [[:alpha:]], which is more in line with what you want, and will (is supposed to) match alpha characters in non-ASCII character sets.

    3. Re:Unacceptable mistakes by Speare · · Score: 2, Informative

      No, [A-z] does not capture all letters. For example, "Å" and "é" are not usually included in the class [A-z], but it is often a part of the class \w.

      --
      [ .sig file not found ]
    4. Re:Unacceptable mistakes by LordoftheWoods · · Score: 2, Informative

      the uppercase letters A-Z are followed by a number of special symbols,

      Indeed. If anyone is interested in why ASCII sticks a few characters in there, it's because it allows you to flip a bit to switch between cases.

    5. Re:Unacceptable mistakes by slim · · Score: 3, Interesting

      BTW. regular expressions present a complete Turing machine.

      Actually no: regular expressions are a great example of a language which is not Turing complete, but is useful nonetheless.

      The classic limitation of regexes is that you can't use them to parse arbitrarily nested brackets -- because there is no concept of a stack. A Turing machine would be able to do this.

      (Researching this post [yes! researching!] I found a couple of mailing list posts from various peoplel suggesting that Perl regexes are Turing complete. If this is true [which I have not established], it's because Perl extends the concept of REs in various ways)

  8. Minor variations by pocari · · Score: 5, Funny
    However, I did feel a little cheated by the fact that several chapters covered essentially the same task, with only minor variations.

    I can relate. I have cookbooks for food that have all these recipes that are nothing but flour, butter, eggs, and sugar. Do we need all these recipes for pancakes, cupcakes, cookies, crepes, waffles, popovers, bread, quick bread, bread sticks? Won't people figure out eventually to put a little less sugar in waffles with savory ingredients?

    Japanese cookbooks are even worse. Soy sauce, sake, mirin...boooooooring!

  9. I personally... by BlueCodeWarrior · · Score: 5, Informative

    ...use 'Mastering Regular Expressions . It's a good book on the topic as well.

    1. Re:I personally... by Bryson · · Score: 3, Informative

      > use 'Mastering Regular Expressions . It's a good book on the topic as well.

      I'm one of the few people who doesn't like Friedl's /Mastering
      Regular Expressions/. (I have the first edition.)

      First, he says that extended regexp engines, such as Perl's, use
      nondeterministic finite automata (NFA). Not true; NFA's can
      accept exactly the same languages as DFA's (deterministic finite
      automata). The extended regexps use search-and-backtrack
      engines.

      Friedl gives some examples of (extended) regexps that have
      catastrophic worst-case behavior, but doesn't present a
      systematic method for recognizing or avoiding them. The naive
      use of extended regexps, mostly by people who think they have
      mastered them, is setting us up for denial-of-service attacks
      based on the worst-case complexity of regular expressions.

      Formal regular expressions are exactly the languages DFA's and
      NFA's can accept. A DFA can parse any string in time
      proportional to the length of the string. Compiling the DFA may
      be exponential time, and space, but at least we find out at
      compile time, not when some attacker figures out a case we
      missed.

  10. add this book to your list by yagu · · Score: 3, Informative

    While I can't vouch for the quality of the reviewed book,if you want something definitive on regular expressions, Mastering Regular Expressions, Second Edition by Jeffrey E. F. Friedl is an absolute must for your professional library. Jeffrey breaks down and then builds back up what regular expressions are and how they work, and offers an entire matrix breakout of the slightly different implementations among the most common utilities (grep, sed, awk, perl...). Not to shill for amazon, but if you select the reviewed book, the "buy this book too, and you get this great price" deal actually includes the Mastering Regular Expressions, Second Edition. . Get 'em both, you won't be sorry.

  11. two problems by EphemeralPhart · · Score: 4, Funny

    Some people, when confronted with a problem, think ``I know, I'll use regular expressions.'' Now they have two problems.

    Jamie Zawinski

  12. Linda Richmond says... by Anonymous Coward · · Score: 5, Funny

    I'm feeling a bit verklempt!

    Talk amongst yourselves!

    Alright, I'll give you a tawpic:

    "Regular Expressions are neither regular nor expressions."

    Discuss.

  13. Re:A language in their own right. by smoany · · Score: 2, Informative

    Um, last time I checked, Reg. Exp's are not turing complete. Take the expression O^n 1^n, which can be made by Turing machines. If you can make that for me using a Regular Expression, you deserve a Turing Award. Regular expressions are DFA/NFA complete, not turing complete... not even close!

  14. Re:A language in their own right. by khrtt · · Score: 3, Informative

    Regular expressions are probably the first Turing-complete language to be encapsulated in another Turing-complete language (C).

    Don't you just love to sound like a StarTrek character, with all that fancy terminology?

    Go look up your complexity book - if you have one - regexes are not even close to Turing-complete.

  15. a Cookbook eh? by chiapetofborg · · Score: 3, Funny

    Anyone have any good recipies for [cookies]+ ?

  16. Re:Email RegEx by Sir_Real · · Score: 2, Interesting

    I'm still looking for a good email regex

    Well, you asked for it.

    Actually, I asked for it last week, in #linux on freenode. Scary huh?

  17. Regexes are overused by ryantate · · Score: 5, Informative

    Anyone who drops in regularly on a Perl discussion forum (like perlmonks.org) knows that programmers tend to over-use regular expressions.

    Regexes are actually a pretty poor way to extract information from comma-delimited or tab-delimited files, for example. By the time you're done dealing with escaped commas, escaped tabs, quoting characters (which many CSV and TDT exporters use in addition to commas and tabs), escaped quote characters, escaped newlines, and escaped escape chars, you end up with a super-complicated regex.

    HTML is even more complicated. You have HTML comments and nested tags on top of everything else.

    To validate a simple email address, Jeffrey Friedl in his Mastering Regular Expressions book for O'Reilly writes an *11-page* regex.

    Most of the time the correct answer is not "here is a regex recipe" but rather "here is a simple library to do the job property with a parser", like Text::CSV or HTML::Parser in perl.

    1. Re:Regexes are overused by stratjakt · · Score: 2, Informative

      Of course, the compiled regex will likely be faster than any parsing library you write. So it all depends what you're doing.

      For some sort of system that processes umpteen billion transactions per second, they can be a godsend. For parsing a .conf file once every six months when the machine is rebooted, it's a waste of time.

      It's all about knowing how and when to use the tool. A pneumatic nailgun can save a carpenter hours on a jobsite, but it's a waste of time to set it all up if you only need to knock in one nailhead that's popped through the drywall.

      --
      I don't need no instructions to know how to rock!!!!
    2. Re:Regexes are overused by Black+Perl · · Score: 3, Insightful

      Yes, exactly. Any good book on Regexes should have a chapter on when NOT to use them.

      I see many people trying to use regexes to do parsing, when they should be using a specialized parser.

      --
      bp
    3. Re:Regexes are overused by smittyoneeach · · Score: 2, Informative

      Consider the boost libraries http://boost.org/.

      You get tokenizer, regex, and a parser library (spirit), in sorted by increasing caliber.

      It's all about the right tool for the job.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    4. Re:Regexes are overused by Anonymous Coward · · Score: 4, Funny

      > *11-page* regex.

      I think that's a sure sign of insanity. Or autism at the least.

    5. Re:Regexes are overused by Alan+Shutko · · Score: 2, Insightful

      To validate a simple email address, Jeffrey Friedl in his Mastering Regular Expressions book for O'Reilly writes an *11-page* regex.

      That's not quite fair. That regex validates any RFC822 address, and the syntax allowed isn't simple. Validating things that are currently used is fairly easy, but there's a lot of historical baggage in RFC822 addressing.

    6. Re:Regexes are overused by 2short · · Score: 3, Insightful

      "an *11-page* regex."

      That's insane. My feelings on Regexes were set early in my career. I discovered them, and like many started using them everywhere. Then in a code review, my boss pointed to one particularly complex one and said "See, there's why you shouldn't try to do such complex things with regular expressions, this one has a bug" "Where?" says me. "Let's leave that as an exercise for the student. Come ask me if you can't figure it out in an hour or so." Well, I certainly wasn't going to admit defeat, even though it took me several hours to find the rather subtle problem. So I went back and demanded to know how he had spotted it so fast. And he said "I didn't. It was a regex 3 lines long. It had to have a bug."

  18. Regex Coach helps building Regexp by uss_valiant · · Score: 5, Informative

    Regex Coach

    This program assists you building regular expressions. I've never used it (real men code regexp at once and it works). But some friends recommend it.

    1. Re:Regex Coach helps building Regexp by DigitalDeviation · · Score: 2, Informative

      Regex Coach is nice for those long regexs that you may have missed an escape somewhere. I write most regexs myself, but I'm no guru at it. Regex Coach is a nice verification that the regex works (particularly for extracting something from a large string).

  19. Re:cant get used to them by Anonymous Coward · · Score: 2, Informative
    regular expressions are nice and all but i still cant get used to them .. a good manual should be kept handy at all times. [ ... ]
    Suggestions are welcome.

    I have a suggestion. Write a few regular expressions to get your brain refreshed on them, then go read this excellent article on how regular expressions work. At the very least, it will clear some confusing things up. Most likely you'll find that having a better understanding of the underlying concepts will make it easier for you to work with regular expressions day to day.

    Also, it helps if you are familiar with finite state machines. I learned about them in a couple classes while getting my CS degree, but they're not that hard and most people should be able to grasp them without any kind of formal CS training.

  20. Re:cant get used to them by Waffle+Iron · · Score: 2, Informative
    regular expressions are nice and all but i still cant get used to them

    They may be kind of hard to get used to, but not has hard as writing, debugging and maintaining a dozen or more lines of custom string parsing code for each case where you would use one.

  21. Re:cant get used to them by halber_mensch · · Score: 4, Informative

    A good starting point is to understand finite automata and regular languages first. See http://en.wikipedia.org/wiki/Automata_theory/ for a good first reference on automata. If you can grok automata, regular expressions will click with you.

    --
    perl -e "eval pack(q{H*},join q{},qw{70 72696e74207061636b28717b482a7d2c717b343 637323635363534323533343430617d293b})"
  22. Different flavors? by dpbsmith · · Score: 3, Informative

    In an average month, I use regular expressions as implemented in Microsoft Visual C++ 6.0, BBEdit Lite, TextWrangler, Apple MPW, and REALBasic. Every single one of them has _significant_ differences in syntax and semantics.

    My understanding is that even the UNIX world sports several different flavors of regular expression in grep, egrep, fgrep, etc.

    The biggest barrier to _my_ use of regular expressions is that every time I switch from one regular expression context to another, it takes me a good half hour to refresh my memory of what does and doesn't work in each environment.

  23. HTML, XML, CSV, but why? by AGTiny · · Score: 3, Interesting

    Of course everyone should know how to build a regex, but why take time discussing how to parse common formats such as HTML, XML, CSV, and so on? Every language likely has a good standard module/library/package that does it all for you, hopefully in the most efficient way, and gives you an easy API. I write Perl, and have used XML::*, HTML::*, DBD::CSV, Text::CSV, the list goes on. No need to write a single regex there. Another good set of modules is Regexp::Common, giving you correct regexes for parsing semi-hard things like IP addresses, MAC addresses, phone numbers, etc.

  24. Free Alternative by MudButt · · Score: 4, Informative

    This is free... And interactive...
    http://www.regexlib.com/

  25. Try them out by DavidNWelton · · Score: 5, Insightful

    Sometimes, with complex regexp's, it's handy to be able to build them incrementally. I know it's just one of many, but I wrote a little tool that's handy for this. It's called regexpviewer, and it's available here:

    http://www.dedasys.com/freesoftware/applications.h tml

    Perhaps other people can recommend other tools they've found useful for learning/building regular expressions.

    1. Re:Try them out by c_ollier · · Score: 3, Interesting

      The Regulator is a nice Open Source tool, but Windows only. It integrates expressions from RegExLib.com, and has syntax highlighting & brace matching.

  26. About 279 pages too long by natoochtoniket · · Score: 4, Insightful
    I have a huge, 1000+ page Betty Crocker cookbook which I hardly ever use. It gives detailed recipes for particular dishes, but nothing that helps me to just throw a dinner together. And nothing that helps me to create anything new.

    My very favorite recipe book is a tiny little thing of about 40 pages. For each kind of meat and each kind of vegetable, it lists what spices and sauces go well with it, how long and how hot to cook it, and how to tell when it is done. There is a little section on how to make about a dozen differnet sauces. That's it.

    A programming language has syntax and semantics. For regular expressions, Chomsky gave both fully in his original paper on the subject. The added conveniences that some utilities provide are all listed in their respective man pages. The entire subject, if it were collected together, should be about 10 pages. With some explanation of language theory, grammars, and such, the whole might be worth a chapter. Get out an undergraduate compiler-theory book (such as Aho/Sethi/Ullman). They have less than a chapter on regular expressions, and they cover the topic fairly well.

    But, I suppose, there is a difference between a cookbook that is made for cooks to use as a reference, and a cookbook that is made for non-cooks to follow by rote. Learn how to cook. You will be surprised how seldom you actually refer to the 1000+ page cookbooks.

  27. Re:cant get used to them by B'Trey · · Score: 3, Informative

    If you really want to understand regexes, get Jeffrey E. E. Friedl's "Mastering Regular Expressions" from O'Reilly. It's much deeper than the casaul reader will ever need, but if you get through it you will certainly know how regexes work from both a user perspective and from a regex engine perspective.

    --

    "The legitimate powers of government extend only to such acts as are injurious to others." Thomas Jefferson.

  28. ignorance is bliss by RelliK · · Score: 2, Informative
    If you want more of a challenge, try writing a regular expression that find any tags along with anything in between using only greedy matching.

    duh! Repeat after me: HTML is not a regular language. There is no regular expression that can match it. The problem arises when people try to use regular expressions without understanding what they are. But, as the saying goes, when the only tool you have is a hammer, everything looks like a nail...

    --
    ___
    If you think big enough, you'll never have to do it.
    1. Re:ignorance is bliss by DeadSea · · Score: 2, Informative
      > duh! Repeat after me: HTML is not a regular language. There is no regular expression that can match it.

      Script tags cannot be nested which makes that portion of html able to be matched by a regular expression.

      --
      Currency conversion calculator

  29. check out regex coach if you want to learn by Anonymous Coward · · Score: 2, Interesting

    I found this tool while doing my undergrad. Having this tool and playing with it showed me how to understand and how to sucessfully write regexs. 5 minutes of playing with it and you be enlightened.

    http://www.weitz.de/regex-coach/

  30. Re:Regexes How2 by softcoder · · Score: 5, Informative

    In addition to a good book, or even INSTEAD of a good book, download and use THE REGEX COACH
    http://www.weitz.de/regex-coach/

    It is a very very nice interactive pgm that lets you debug REGEXES on the fly visually, by feeding them sample text.

  31. :help pattern by digitect · · Score: 3, Informative

    Of course, if you use the one true text editor, all you need to know about regular expressions is:

    :help pattern

    :)

    --
    There is no need to use a SlashDot sig for SEO...
  32. Re:Typical... by Monkelectric · · Score: 3, Insightful

    I had a brief skirmish with the tech book publishing industrty (and believe me thats the right word). The real problem is they pay authors BY THE PAGE so their incentive is to write flowery, lengthy language which conveys as little information in as much space as possible. This in turn justifies high book prices and higher author royalties.

    --

    Religion is a gateway psychosis. -- Dave Foley