Documention for: like.r
Created by: greggirwin
on: 16-Oct-2006
Format: html
Downloaded on: 21-Feb-2024

One of the main uses for this function, and the reason I'm posting 
it now, is for file globbing. The pattern syntax is very close to 
common globbing syntax, and isn't a full regex engine by any stretch 
of the imagination. I'm posting it now because I have a FILE-LIST 
function I plan to post soon, and it uses this function, so people 
who want to use FILE-LIST will need this.

Don't be shy about telling me how awful it is. I wrote it shortly 
after finding REBOL, and it was a tool to help me learn about PARSE 
-- generating rules from the pattern string. I haven't revisited 
any of that to improve it.

Here are some examples, given as string, pattern, and expected result 

    "abc_()!@^#%_def`z"  "abc*def?[xyz]" true

    "abc_defx"  "abc*def[xyz]"  true
    "abc_defx"  "abc?def[xyz]"  true
    "abc__defx" "abc??def[!xyz]" false
    "abc__defx" "abc??def[xyz]" true

    "abc_defx"  {abc?def[!x-z]} false
    "abc_defx"  {abc?def[x-z]}  true

    "abcdxxxxxx"    "abc?*"     true
    "avbcvz"        "a*z"       true
    "12345_xxx"     "*_*"       true
    "filename.txtdfdf" "*.txt*" true
    "abcdefg"       "ab*f[ghi]" true

    "]ab*&&&fg?$^^^- `~019["

    "]ab*&&&fg?$^^^- `~019["
    "]ab[*]*f[ghi][?]?*^- ??![]###[[]"

    "Gregg 12340 Irwin" "* ####*"   true
    " 12340"            "* ####*"   true
    "Gregg 123400"      "* ####*"   true
    " 12340 Irwin"      "* ####*"   true

    "Looking for [ in text"  "Looking for?[[]*"    true

    "Looking for [ in text"  "*[[]*"   true

    "Looking for ] in text"  "*[[]*"   false

    %/c/temp/test-1.jpg                    %/c/temp/*.jpg	true
    %/c/temp/extra-dir/test-1.jpg	%/c/temp/*.jpg	true
    %/c/temp/extra-dir/test-1.jpg	"/c/temp/*[!/].jpg"	false
    %/c/temp/extra-dir/test-1.jpeg	%/c/temp/*.jpg	false