View script | License | Download documentation as: HTML or editable |
Download script | History | Other scripts by: greggirwin |
10-Sep 0:08 UTC
[0.055] 11.355k
[0.055] 11.355k
Documentation for: like.rOne 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 triplets: "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[*]*f[ghi]ÿ[?]?*`~[©»¨§]###[[]" true "]ab*&&&fgÿ?$^^^- `~¨019[" "]ab[*]*f[ghi]ÿ[?]?*^- ??![©»§]###[[]" false "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 |