Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Matching RE's - pattern matching

From: arolls:bigpond:au at: 23-Mar-2001 18:15

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.