RFE: grep is really pathetic sometimes

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 51296
interpreted = N
texte = I love using regular expressions to process my text (which is why I spend most of my time using Perl these days). However, one of my other developers came to me to ask why a particular grep was working the way it was. The code is as follows: [grep search=^([A-Z0-9][0-9A-Z])([0-9A-Z][0-9A-Z][0-9A-Z])&replace=\1/\2/][getchars start=1&end=5][SKU][/getchars][/grep] That *should* match the first two characters (as \1) and the next three (as \2). It always seemed to work when we were only looking at numbers, but we had to extend it to work with characters as well as and it suddenly started matching twice for one item. For SKU=TROUTPRINT.JPG, we expected it to return "TR/OUT/", but it would return "TR/OUT/PR/INT" instead. It turns out that [grep] doesn't understand the beginning of line (BOL) anchor "^" character. Consequently, the pattern was matching twice (because this item had a longer SKU than the other items). This is very annoying and vastly reduces the usabililty of [grep] for me. Why couldn't WebCat provide a real regex engine like Perl Compatible Regular Expressions: http://www.pcre.org/ instead of whatever hodgepodge of code it currently has? At the very least, WebCat should have thrown some sort of an error for the "^" which it doesn't understand. John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. RFE: grep is really pathetic sometimes ( John Peacock 2003)
I love using regular expressions to process my text (which is why I spend most of my time using Perl these days). However, one of my other developers came to me to ask why a particular grep was working the way it was. The code is as follows: [grep search=^([A-Z0-9][0-9A-Z])([0-9A-Z][0-9A-Z][0-9A-Z])&replace=\1/\2/][getchars start=1&end=5][SKU][/getchars][/grep] That *should* match the first two characters (as \1) and the next three (as \2). It always seemed to work when we were only looking at numbers, but we had to extend it to work with characters as well as and it suddenly started matching twice for one item. For SKU=TROUTPRINT.JPG, we expected it to return "TR/OUT/", but it would return "TR/OUT/PR/INT" instead. It turns out that [grep] doesn't understand the beginning of line (BOL) anchor "^" character. Consequently, the pattern was matching twice (because this item had a longer SKU than the other items). This is very annoying and vastly reduces the usabililty of [grep] for me. Why couldn't WebCat provide a real regex engine like Perl Compatible Regular Expressions: http://www.pcre.org/ instead of whatever hodgepodge of code it currently has? At the very least, WebCat should have thrown some sort of an error for the "^" which it doesn't understand. John -- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ John Peacock

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

[OT] Conversion from QuickMail Pro (2002) WebCat2b13MacPlugIn - [include] (1997) Too Much Rootbeer Free Offer (1997) [WebDNA] thisAutonumber? (2011) [addlineitems] display (1997) HELP-1!!! (1998) Follow-up to listfiles bug report ... (2003) RAM variables (1997) Nested search (1997) Software Update OSX (2003) latest version? (1998) Database Program (1997) FedEx Rate Calculator Completed (2002) WebMerchant? (1998) problem with WebDNA Command (2004) converting tabs (1997) Combining search criteria in a context? (1998) Not really WebCat- (1997) Email (2000) WebCat2b13MacPlugIn - [showif][search][/showif] (1997)