Re: Grep help
This WebDNA talk-list message is from 2004
It keeps the original formatting.
numero = 58773
interpreted = N
texte = 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 numbersHTHJohn-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 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:
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 numbersHTHJohn-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 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:
Webcat 2.0.1 date math bug -> Crash! (1997)
shipcost (1997)
[WebDNA] Database Column Update (2015)
XML WebDNA Problems (2000)
WebCat editing, SiteGuard & SiteEdit (1997)
WebCat2: Formulas.db question (1997)
WebDNA Solutions ... sorry! (1997)
[WebDNA] CICADA (2009)
PCS Frames-Default page is solution! (1997)
Banner Ad example (Typhoon) and WebCatalog (1997)
best way to limit # of attempts to login to protected page? (2000)
trouble updating records in database (1998)
[carts] and databases (1997)
Off-Topic: Optimal WebSTAR settings for WebDNA plugin v4.5 (2002)
Summary search -- speed (1997)
WebMerchant? (1998)
free shipping (2000)
WebCat2.0b15-to many nested [xx] tags (1997)
Problems searching from a FORM (1997)
Math with Time (1997)