Marcus,

This is what I use in my 'ls function found here:
http://users.bigpond.net.au/datababies/anton/rebol/dir-utils.r

This matches filenames in a directory list:

 foreach file list [
     match: find/any/match file :pattern
     if match [
         if (index? tail file) = (index? match) [

                 ; this is where you can say it actually matches

             if error? try [
                 append either dir? file [dir-list] [file-list] file
             ] []
         ]
     ]
 ]

'pattern is a string such as "r*.r"

In my quick testing the /case refinement works 
with this too - eg.

 >> file: to-string %Rtest.blah
 == "Rtest.blah"
 >> match: find/case/any/match file "R*.*"
 == ""
 >> (index? tail file) = (index? match)
 == true

Regards,

Anton.


> Warning! This mail contains a lot of whining. Don't read it if you easily
> get bored. You have been warned, so bear with me.
> 
> 
> Ok, so I start out thinking this will work:
> 
> >> "" = find/case/any/match "user.r" "*.r"
> == false
> 
> Hmm, so the dot is a wildcard (equal to ?) and needs to be escaped:
> 
> >> "" = find/case/any/match "user.r" "*^.r"
> == false
> 
> So it didn't work, let's try another RE construct:
> 
> "" = find/case/any/match "user.r" "*[.]r"
> == true
> 
> Aha, that looks better, but let's check it first:
> 
> >> "" = find/case/any/match "user" "*[.]r"
> == true
> 
> Oh no! The dot is still acting as a wildcard. What to do now?
> Perhaps we can escape it within the blocks:
> 
> >> "" = find/case/any/match "user" "*[^.]r"
> == true
> 
> Nope, didn't work. Let's try something else:
> 
> >> "" = find/case/any/match "user" "*[\.]r"
> == false
> >> "" = find/case/any/match "user.r" "*[\.]r"
> == true
> 
> Aha, this could be it! But wait, perhaps... :
> 
> >> "" = find/case/any/match "user\r" "*[\.]r"
> == true
> 
> Ouch, it seems to be a choice between backslash and dot. Or is it?
> 
> >> "" = find/case/any/match "user r" "*[\.]r"
> == true
> 
> AARGH! Does it even work at all?
> 
> >> "" = find/case/any/match "user qwerty r" "*[ gargle ]r"
> == true
> 
> Double-AARGH! Oh well, whatever those brackets do, I better stop using
> them. Let's see... :
> 
> >> "" = find/case/any/match "user qwerty r" "*gargler"
> == false
> 
> Phew, I was starting to worry. Let's check again:
> 
> >> "" = find/case/any/match "user qwerty r" "*garglr"
> == true
> 
> What???!!! Oh well, before we give, better check the PDF. Hmm, seems they
> have put /match before /any there. Wonder why... :
> 
> >> "" = find/case/match/any "user qwerty r" "*garglr"
> == true
> 
> Nope. Oh well, one last try:
> 
> >> "" = find/match/any "user qwerty r" "*garglr"
> == false
> 
> Yes! This is it, it was a problem with /case. So we get:
> 
> >> "" = find/match/any "user.r" "*.r"
> == true
> >> "" = find/match/any "user" "*.r"
> == false
> 
> Good good. On the other hand, we also get:
> 
> >> "" = find/match/any "user.r" "*.R"
> == true
> 
> Not good. What if we put /case back in there:
> 
> >> "" = find/match/any/case "user.r" "*.R"
> == false
> >> "" = find/match/any/case "user.r" "*.r"
> == false
> 
> And so we're back where we started. Sigh, I guess I better write a RE to
> Rebol parserule translator. Unless such a thing exists already...?
> 
> Some other examples:
> 
> >> find/case/any "user.R" '*r.R
> == none
> >> find/case/any "user.R" '*r.*
> == none
> >> find/case/any "user.R" '*r.r
> == "user.R"
> >> find/case/any "user.R" '*r.?
> == "user.R"
> 
> Only the last one is correct. That pretty much says it all.
> 
> Marcus

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to