Re: Grep -- remove extra returns first
This WebDNA talk-list message is from 2003
It keeps the original formatting.
numero = 52118
interpreted = N
texte = I've been spending a lot of time with grep lately and I'm not sure Iunderstand exactly what you're trying to do. The result I proposed stripsall text but the URI which was what I thought you wanted. I cannot imaginethat there are returns in the URI. Also my search just returned the oneURI. You will have difficulty if you want to return the surrounding text.Are you looking just to make the URI into an anchor href as Rajeev keepstrying to do and keep the remaining text intact?If so, try this:[grep search=(http://[^ ]*)&replace=\1][mystring][/grep]Now each portion of the string will be returned in the result. The URI is\1 so you can process that however you like. If you want to make the URIinto an anchor, try:[grep search=(http://[^ ]*)&replace=\1
\1][mystring][/grep]I tested this and it seems to work for me just fine. I get the URI in aclickable link even with returns in the variable. The notion of blockingthe space in the URI only works if you expect that the URI will not havespaces. Otherwise, you'll need to rethink this.If you are trying to compare the Web Cat grep to the terminal grep in OS Xthey're a little different. Web Cat seems to return lines that don't matchthe search criteria. So in that sense it's different from true grep wherenon-matching lines are skipped. This should illustrate my point:Mystring=asdfafAsdfAaa http://www.cnn.com adAsdGrepping mystring at the terminal for http://[^ ] will return only the line:Aaa http://www.cnn.com adGrepping mystring in Web Cat returns all of mystring plus or minus anyreplacements. If grepped as above, Web Cat returns:asdfafAsdfAaa
http://www.cnn.com adAsdThus, Web Cat returns lines that do not match the search result. It's morelike a search and replace all function with regular expressions than a truegrep that returns only matching lines.Billon 8/7/03 10:40 PM, Jesse Williams-Proudman at j.list@ninewire.com wrote:> On 8/7/03 7:22 PM, "William DeVaul"
wrote:> >> [grep search=.*(http://[^ ]*).*&replace=\1][grep>> search=[%0D%0A%0B]&replace=][mystring][/grep][/grep]> > Ok, this is a good start, but then the problem becomes formatting. This is> being used in my DNAForum software and I need to have posts be formatted> correctly (IE, the rtusn need to exist).> -------------------------------------------------------------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:
I've been spending a lot of time with grep lately and I'm not sure Iunderstand exactly what you're trying to do. The result I proposed stripsall text but the URI which was what I thought you wanted. I cannot imaginethat there are returns in the URI. Also my search just returned the oneURI. You will have difficulty if you want to return the surrounding text.Are you looking just to make the URI into an anchor href as Rajeev keepstrying to do and keep the remaining text intact?If so, try this:[grep search=(http://[^ ]*)&replace=\1][mystring][/grep]Now each portion of the string will be returned in the result. The URI is\1 so you can process that however you like. If you want to make the URIinto an anchor, try:[grep search=(http://[^ ]*)&replace=\1\1][mystring][/grep]I tested this and it seems to work for me just fine. I get the URI in aclickable link even with returns in the variable. The notion of blockingthe space in the URI only works if you expect that the URI will not havespaces. Otherwise, you'll need to rethink this.If you are trying to compare the Web Cat grep to the terminal grep in OS Xthey're a little different. Web Cat seems to return lines that don't matchthe search criteria. So in that sense it's different from true grep wherenon-matching lines are skipped. This should illustrate my point:Mystring=asdfafAsdfAaa http://www.cnn.com adAsdGrepping mystring at the terminal for http://[^ ] will return only the line:Aaa http://www.cnn.com adGrepping mystring in Web Cat returns all of mystring plus or minus anyreplacements. If grepped as above, Web Cat returns:asdfafAsdfAaa http://www.cnn.com adAsdThus, Web Cat returns lines that do not match the search result. It's morelike a search and replace all function with regular expressions than a truegrep that returns only matching lines.Billon 8/7/03 10:40 PM, Jesse Williams-Proudman at j.list@ninewire.com wrote:> On 8/7/03 7:22 PM, "William DeVaul" wrote:> >> [grep search=.*(http://[^ ]*).*&replace=\1][grep>> search=[%0D%0A%0B]&replace=][mystring][/grep][/grep]> > Ok, this is a good start, but then the problem becomes formatting. This is> being used in my DNAForum software and I need to have posts be formatted> correctly (IE, the rtusn need to exist).> -------------------------------------------------------------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/
William DeVaul
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:
WebMerchant 1.6 and SHTML (1997)
RE: WebDNA-Talk searchable? (1997)
[WebDNA] Variable mystery (2009)
autosensing lanague selection (1997)
Help! WebCat2 bug (1997)
Multithreading of [replace] (1999)
emailer (1997)
Running _every_ page through WebCat-error.html (1997)
WebMerchant and Mac Auth Hub Help Please (1999)
Online reference (1997)
RE: creating writefile data from a nested search (1997)
combining strings (1997)
[WebDNA] [listwords] seems especially slow (amongst the looping contexts) (2010)
# of real domains on 1 web server (1997)
Can you do this??? and other stuff (1997)
WriteFile and returns... (2000)
Location of Browser Info.txt file (1997)
Mac Programs (1998)
Purchased cart being overwritten - still !?? (1997)
pc (1997)