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.shtmlTry 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 -0500To: "WebDNA Talk" Subject: Re: Grep helpThat 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,PatOn 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:
http://www.anybrowser.org/bbedit/grep.shtmlTry 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 -0500To: "WebDNA Talk" Subject: Re: Grep helpThat 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,PatOn 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:
Update quantity (2000)
prev & Next commands (1999)
Command=Showcart? (2000)
Webstar 1.3.1 PPC (1997)
Changes to [ReturnRaw] in 3.0 (1998)
Frames and cart values (1998)
credit card - Revised (1997)
E-mailer error codes (1997)
[HIDEIF] inside [FOUNDITEM] (1997)
ooops...WebCatalog [FoundItems] Problem - LONG - (1997)
WebCatalog as a ListServ (1998)
Free pack for the New UPS ratings and services tool (2000)
Arrays (2000)
[PROTECT] Problem (2003)
WebCatalog/Mac 2.1b2 New Features (1997)
Running 2 two WebCatalog.acgi's (1996)
Test - sorry (2003)
$Append for Users outside the ADMIN group (1997)
[WebDNA] Grep help - catch all URLs (2010)
Emailer setup (1997)