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 I understand exactly what you're trying to do. The result I proposed strips all text but the URI which was what I thought you wanted. I cannot imagine that there are returns in the URI. Also my search just returned the one URI. 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 keeps trying 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 URI into 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 a clickable link even with returns in the variable. The notion of blocking the space in the URI only works if you expect that the URI will not have spaces. Otherwise, you'll need to rethink this. If you are trying to compare the Web Cat grep to the terminal grep in OS X they're a little different. Web Cat seems to return lines that don't match the search criteria. So in that sense it's different from true grep where non-matching lines are skipped. This should illustrate my point: Mystring=asdfaf Asdf Aaa http://www.cnn.com ad Asd Grepping mystring at the terminal for http://[^ ] will return only the line: Aaa http://www.cnn.com ad Grepping mystring in Web Cat returns all of mystring plus or minus any replacements. If grepped as above, Web Cat returns: asdfaf Asdf Aaa http://www.cnn.com ad Asd Thus, Web Cat returns lines that do not match the search result. It's more like a search and replace all function with regular expressions than a true grep that returns only matching lines. Bill on 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:

    
  1. Re: Grep -- remove extra returns first ( William DeVaul 2003)
  2. Re: Grep -- remove extra returns first ( "Rajeev Kumar" 2003)
  3. Re: Grep -- remove extra returns first ( Jesse Williams-Proudman 2003)
  4. Re: Grep -- remove extra returns first ( "Rajeev Kumar" 2003)
  5. Re: Grep -- remove extra returns first ( Jesse Williams-Proudman 2003)
  6. Re: Grep -- remove extra returns first ( William DeVaul 2003)
  7. Re: Grep -- remove extra returns first ( Jesse Williams-Proudman 2003)
  8. Re: Grep -- remove extra returns first ( William DeVaul 2003)
I've been spending a lot of time with grep lately and I'm not sure I understand exactly what you're trying to do. The result I proposed strips all text but the URI which was what I thought you wanted. I cannot imagine that there are returns in the URI. Also my search just returned the one URI. 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 keeps trying 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 URI into 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 a clickable link even with returns in the variable. The notion of blocking the space in the URI only works if you expect that the URI will not have spaces. Otherwise, you'll need to rethink this. If you are trying to compare the Web Cat grep to the terminal grep in OS X they're a little different. Web Cat seems to return lines that don't match the search criteria. So in that sense it's different from true grep where non-matching lines are skipped. This should illustrate my point: Mystring=asdfaf Asdf Aaa http://www.cnn.com ad Asd Grepping mystring at the terminal for http://[^ ] will return only the line: Aaa http://www.cnn.com ad Grepping mystring in Web Cat returns all of mystring plus or minus any replacements. If grepped as above, Web Cat returns: asdfaf Asdf Aaa http://www.cnn.com ad Asd Thus, Web Cat returns lines that do not match the search result. It's more like a search and replace all function with regular expressions than a true grep that returns only matching lines. Bill on 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)