Re: Grep help

This WebDNA talk-list message is from

2004


It keeps the original formatting.
numero = 58776
interpreted = N
texte = http://www.anybrowser.org/bbedit/grep.shtml Try the above link for a simpler explanation. If you have OS X, try man grep at the command line. I'd also point out the regular expressions (or regex) can be used lots of places outside of the grep command in WebDNA. sed, Javascript and lots of other examples are out there. That said, the WebDNA version of grep/regex can require some coaxing to work properly. Bill -----Original Message----- From: Patrick McCormick Sent: Tue, 13 Jul 2004 13:07:37 -0500 To: "WebDNA Talk" Subject: Re: Grep help That helps tremendously. Grep references usually get way into the syntax of matching before they get to techniques for replacing. Without knowing that I have a way to manage replacements, I've stopped reading all the details about matching. Thanks, Pat On Jul 13, 2004, at 12:35 PM, John Peacock wrote: > Patrick McCormick wrote: > >> How do I save part of a string with grep? > > By capturing the text you want to save using parentheses, then using > references in the replace term. > >> I want the state and the zip chunks to remain intact, but only >> replace the space between them with a tab. Is Grep capable of that by >> itself? > > You want to get a book on regular expressions; O'Reilly's "Mastering > Regular Expressions" is the best I am aware of. Your data includes > embedded spaces (i.e "SPRING VALLEY") so your regex has to be somewhat > more complicated because of that. > > I think this might do what you want: > > search=([A-Z ]+) +([A-Z][A-Z]) ([0-9]+)$ > replace=\1\t\2\t\3 > > (obviously that has to be put into WebDNA [grep] form). That regex > works like this: > > ([A-Z ]+) = match 1 or more letters plus embedded space > + = followed by 2 or more spaces > ([A-Z][A-Z]) = match exactly 2 letters > = followed by 1 space > ([0-9]+) = match 1 or more numbers > > HTH > > 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/ > ------------------------------------------------------------- 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/ ------------------------------------------------------------- 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. Re: [WebDNA] Grep help - catch all URLs (Tom Duke 2010)
  2. Re: [WebDNA] Grep help - catch all URLs (Stuart Tremain 2010)
  3. [WebDNA] Re: Grep help - catch all URLs (Tom Duke 2010)
  4. [WebDNA] Grep help - catch all URLs (Tom Duke 2010)
  5. Re: OT Grep Help ( Donovan Brooke 2008)
  6. Re: OT Grep Help ( Marc Thompson 2008)
  7. Re: OT Grep Help ( Donovan Brooke 2008)
  8. Re: OT Grep Help ( Marc Thompson 2008)
  9. OT Grep Help ( Donovan Brooke 2008)
  10. Re: Grep Help ( Alex McCombie 2007)
  11. Re: Grep Help ( Gary Krockover 2007)
  12. Re: Grep Help ( thierry 2007)
  13. Re: Grep Help ( "Gary Krockover" 2007)
  14. Re: Grep Help ( Donovan Brooke 2007)
  15. Re: Grep Help ( Gary Krockover 2007)
  16. Re: Grep Help ( Donovan Brooke 2007)
  17. Re: Grep Help ( Alex McCombie 2007)
  18. Re: Grep Help ( "Olin Lagon" 2007)
  19. Grep Help ( Alex McCombie 2007)
  20. Re: Grep help ( Lester 2005)
  21. Re: Grep help ( Lester 2005)
  22. Re: Grep help ( devaulw@onebox.com 2005)
  23. Grep help ( Lester 2005)
  24. Re: [OT] grep help ( John Peacock 2004)
  25. Re: [OT] grep help ( devaulw@onebox.com 2004)
  26. [OT] grep help ( Mark Derrick 2004)
  27. Re: Grep help needed ( Gary Krockover 2004)
  28. Re: Grep help needed ( Bob Minor 2004)
  29. Re: Grep help needed ( William DeVaul 2004)
  30. Grep help needed ( Gary Krockover 2004)
  31. Re: Grep help ( devaulw@onebox.com 2004)
  32. Re: Grep help ( Patrick McCormick 2004)
  33. Re: Grep help ( John Peacock 2004)
  34. Re: Grep help ( Patrick McCormick 2004)
  35. Re: Grep help ( devaulw@onebox.com 2004)
  36. Re: Grep help ( Patrick McCormick 2004)
  37. Grep help ( Patrick McCormick 2004)
  38. Re: Grep help ( Clint Davis 2004)
  39. Re: Grep help ( "Rajeev Kumar" 2004)
  40. Re: Grep help ( John Peacock 2004)
  41. Grep help ( "Rajeev Kumar" 2004)
  42. Re: WebDNA Grep help wanted ( Kenneth Grome 2004)
  43. Re: WebDNA Grep help wanted ( Gary Krockover 2004)
  44. Re: WebDNA Grep help wanted ( Kenneth Grome 2004)
  45. Re: WebDNA Grep help wanted ( William DeVaul 2004)
  46. Re: WebDNA Grep help wanted ( Kenneth Grome 2004)
  47. Re: WebDNA Grep help wanted ( Gary Krockover 2004)
  48. Re: WebDNA Grep help wanted ( devaulw@onebox.com 2004)
  49. Re: WebDNA Grep help wanted ( devaulw@onebox.com 2004)
  50. Re: WebDNA Grep help wanted ( "Andrew Simpson" 2004)
  51. Re: WebDNA Grep help wanted ( Palle Bo Nielsen 2004)
  52. Re: WebDNA Grep help wanted ( "Andrew Simpson" 2004)
  53. WebDNA Grep help wanted ( Palle Bo Nielsen 2004)
  54. Grep Help ( Donovan Brooke 2003)
  55. Re: Grep Help ( Matthew Bohne 2003)
  56. Grep Help ( Matthew Bohne 2003)
  57. Re: Grep Help ( Stuart Tremain 2003)
  58. Grep Help ( Jesse Williams-Proudman 2003)
  59. Re: Grep Help ( William DeVaul 2003)
  60. Grep Help ( Jesse Williams-Proudman 2003)
  61. Re: Grep Help ( Jesse Williams-Proudman 2003)
  62. Re: Grep Help ( Jesse Williams-Proudman 2003)
  63. Re: Grep Help ( Alain Russell 2003)
  64. Grep Help ( Jesse Williams-Proudman 2003)
  65. Re: Grep help, please ... (Nitai @ ComputerOil 2003)
  66. Re: Grep help, please ... (Kenneth Grome 2003)
  67. Re: Grep help, please ... (Nitai @ ComputerOil 2003)
  68. Re: Grep help, please ... (Dennis J. Bonsall, Jr. 2003)
  69. Re: Grep help requested (Jim Lanford 2002)
  70. Re: GREP Help (John Peacock 2001)
http://www.anybrowser.org/bbedit/grep.shtml Try the above link for a simpler explanation. If you have OS X, try man grep at the command line. I'd also point out the regular expressions (or regex) can be used lots of places outside of the grep command in WebDNA. sed, Javascript and lots of other examples are out there. That said, the WebDNA version of grep/regex can require some coaxing to work properly. Bill -----Original Message----- From: Patrick McCormick Sent: Tue, 13 Jul 2004 13:07:37 -0500 To: "WebDNA Talk" Subject: Re: Grep help That helps tremendously. Grep references usually get way into the syntax of matching before they get to techniques for replacing. Without knowing that I have a way to manage replacements, I've stopped reading all the details about matching. Thanks, Pat On Jul 13, 2004, at 12:35 PM, John Peacock wrote: > Patrick McCormick wrote: > >> How do I save part of a string with grep? > > By capturing the text you want to save using parentheses, then using > references in the replace term. > >> I want the state and the zip chunks to remain intact, but only >> replace the space between them with a tab. Is Grep capable of that by >> itself? > > You want to get a book on regular expressions; O'Reilly's "Mastering > Regular Expressions" is the best I am aware of. Your data includes > embedded spaces (i.e "SPRING VALLEY") so your regex has to be somewhat > more complicated because of that. > > I think this might do what you want: > > search=([A-Z ]+) +([A-Z][A-Z]) ([0-9]+)$ > replace=\1\t\2\t\3 > > (obviously that has to be put into WebDNA [grep] form). That regex > works like this: > > ([A-Z ]+) = match 1 or more letters plus embedded space > + = followed by 2 or more spaces > ([A-Z][A-Z]) = match exactly 2 letters > = followed by 1 space > ([0-9]+) = match 1 or more numbers > > HTH > > 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/ > ------------------------------------------------------------- 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/ ------------------------------------------------------------- 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/ devaulw@onebox.com

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:

Sku numbers (1997) Templates for Customer Database? (1997) Limit to Field Length in DB (1998) WebCat2 - storing unformatted date data? (1997) Db crash in win98 (2000) ftp to webstar (2001) To Err or Not Custom Error (1999) [append] vs. [appendfile] delta + question? (1997) MySQL and Decimals (2004) [showif] with ! (2000) WC Database Format (1997) RFE: Accessing Server Environment Variables (2003) How Many SKU's is enough? (1997) WebCatalog-NT?'s (1996) listfiles-looking for slick solution (1997) syntax for contains a word - oops (2002) WC1.6 to WC2 date formatting (1997) New Guestbook Source (1997) Re:emailer 150 (1997) Help!!!! Purchases not going through! FIXED! (1997)