Re: Re(2): grep matching

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 47918
interpreted = N
texte = Laurent -The weird behavior you're seeing is not necessarily wrong, it's just one example of how to interpret the grep string.Your original grep search string was: \[(.*)->(.*)\]The (.*) code says match all characters to the end of the string - including the - and ] characters. Apparently the grep library that WebDNA uses then backtracks from the end of the selection until it finds the first (going backwards) matching -> characters, which in your example is actually from the second hyperlink tag, so everything after the first [ and before the last -> gets thrown into the \1 selection.This is why I suggested replacing the first (.*) code with ([^-]*), and the second one with ([^\]]). These say select all characters not listed in the square brackets - that is, select until you find a - or a ], respectively.Unfortunately, WebDNA doesn't handle the end bracket inside the character list properly, so that's why I added the workaround substituting the bracket characters with curly braces first, then searching for the curlies, as described in my previous email.Note that your code works fine in BBEdit, so this one may be chalked up to geographical differences, though I would think the BBEdit result to be more desirable than the WebDNA result in most cases. I think there are enough flaws in WebDNA's grep that it would be worth SM spending some time cleaning it up (and adding an Ignore Case option as well so I can search for brian and find 'Brian or BRIAN as well).- brianOn Thursday, February 20, 2003, at 03:02 AM, laurent pladys wrote:>> I tried everything I could think of to be able to search for an end >> square bracket within a character list (delimited by [] in grep), but >> it will not work. I can search for the character by itself, and I can >> make it work in a character list in BBEdit, but I can't make it work >> in >> WebDNA. > > The weird thing is that if I have only one occurence of [some web site- >> http://www.somewebsite.com] then it works. It stops working when there > are 2 occurences of stuff within brackets because it looks l;ike the > grep > matching happens between the fist open bracket it finds and the last > one, > thus breaking my link building pattern. > See for the live sample which looks > like this : > > bla bla bla > [some web site->http://www.somewebsite.com] > bli bli bli > > changes correctly to > bla bla bla > some web site > bli bli bli > > but > > bla bla bla > [some web site->http://www.somewebsite.com] > bli bli bli > [some other site->http://www.otherwebsite.com] > blu blu blu > > turns to : > > bla bla bla > some web site bli bli bli [some > other site->http://www.otherwebsite.com] blu blu blu > > It is almost working and I don't think it is the same problem you > encountered. I thuink the grep is trying to match the biggest pattern > it > can find where I would like to have the smallest pattern possible. > > That's weird ... > > Laurent -- Brian Fries, BrainScan Software -- http://www.brainscansoftware.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: Re(2): grep matching (Brian Fries 2003)
  2. Re(2): grep matching (laurent pladys 2003)
Laurent -The weird behavior you're seeing is not necessarily wrong, it's just one example of how to interpret the grep string.Your original grep search string was: \[(.*)->(.*)\]The (.*) code says match all characters to the end of the string - including the - and ] characters. Apparently the grep library that WebDNA uses then backtracks from the end of the selection until it finds the first (going backwards) matching -> characters, which in your example is actually from the second hyperlink tag, so everything after the first [ and before the last -> gets thrown into the \1 selection.This is why I suggested replacing the first (.*) code with ([^-]*), and the second one with ([^\]]). These say select all characters not listed in the square brackets - that is, select until you find a - or a ], respectively.Unfortunately, WebDNA doesn't handle the end bracket inside the character list properly, so that's why I added the workaround substituting the bracket characters with curly braces first, then searching for the curlies, as described in my previous email.Note that your code works fine in BBEdit, so this one may be chalked up to geographical differences, though I would think the BBEdit result to be more desirable than the WebDNA result in most cases. I think there are enough flaws in WebDNA's grep that it would be worth SM spending some time cleaning it up (and adding an Ignore Case option as well so I can search for brian and find 'Brian or BRIAN as well).- brianOn Thursday, February 20, 2003, at 03:02 AM, laurent pladys wrote:>> I tried everything I could think of to be able to search for an end >> square bracket within a character list (delimited by [] in grep), but >> it will not work. I can search for the character by itself, and I can >> make it work in a character list in BBEdit, but I can't make it work >> in >> WebDNA. > > The weird thing is that if I have only one occurence of [some web site- >> http://www.somewebsite.com] then it works. It stops working when there > are 2 occurences of stuff within brackets because it looks l;ike the > grep > matching happens between the fist open bracket it finds and the last > one, > thus breaking my link building pattern. > See for the live sample which looks > like this : > > bla bla bla > [some web site->http://www.somewebsite.com] > bli bli bli > > changes correctly to > bla bla bla > some web site > bli bli bli > > but > > bla bla bla > [some web site->http://www.somewebsite.com] > bli bli bli > [some other site->http://www.otherwebsite.com] > blu blu blu > > turns to : > > bla bla bla > some web site bli bli bli [some > other site->http://www.otherwebsite.com] blu blu blu > > It is almost working and I don't think it is the same problem you > encountered. I thuink the grep is trying to match the biggest pattern > it > can find where I would like to have the smallest pattern possible. > > That's weird ... > > Laurent -- Brian Fries, BrainScan Software -- http://www.brainscansoftware.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/ Brian Fries

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:

rn doesn't work on date fields (1998) [date] tag not working on mac 4.0.1 (2000) Multiple cart additions (1997) writing db to disk (1997) OT: SpiderBotLock! (2003) Can this be done? (1997) New WebMerchant/Mac beta available (1997) Base 64 encoding (2001) ShowNext (1997) Date Formats (1997) NT lockup (1998) Nested tags count question (1997) SiteEdit Pro Update Announcement (1997) Download to disk NOT display in browser (2002) Append File help needed (2000) [table] strange behaviour REAL solution (2003) [WebDNA] mod_WebDNA_apache2.2.so: mach-0, but wrong architecture (2010) [isfile] ? (1997) [OT] MS Security Flaw (2000) Major bug report on rootbeer (1997)