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

New find question

 [1/10] from: kpeters::vu-ware::com at: 24-Jun-2005 17:45


Hi all ~ ... files: read %/c/ foreach file files[   if find/any file "p*.htm"= [      read= file ... **Access Error: Cannot open= /C/p3.htm.32105.#01 Why on earth would this file match my= filter? How do I exclude any such= files? TIA, Kai

 [2/10] from: antonr::lexicon::net at: 25-Jun-2005 15:39


This is a well-tested method I use a lot:
>> %"" = find/match/any %p3.htm.32105.#01 "p*.htm"
== false
>> %"" = find/match/any %p3.htm "p*.htm"
== true Anton.

 [3/10] from: volker::nitsch::gmail::com at: 25-Jun-2005 10:28


The difference is the /match. without it, you have basically *your-pattern* , will say, if that pattern is somewhere in the string, its found. with /match you force the ends to match. On 6/25/05, Anton Rolls <[antonr--lexicon--net]> wrote:
> This is a well-tested method I use a lot: > >> %"" = find/match/any %p3.htm.32105.#01 "p*.htm"
<<quoted lines omitted: 10>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [4/10] from: SunandaDH::aol::com at: 25-Jun-2005 5:01


Kai
> files: read %/c/ foreach file files[ if > find/any file "p*.htm" > = [ read= file ... > **Access Error: Cannot open= /C/p3.htm.32105.#01
I'm assuming you *do* have a file called /C/p3.htm.32105.#01 If not, something strange has happened with the read. If you do, then the find *will* match. Try this: (assuming you are looking for p???...???.htm) files: read %/c/ foreach file files [ if all [not dir? file ;; eliminate folders %.htm = suffix? lowercase file ;; only .htm at the end #"p" = first file ][ ;; beginning with p or P print file ] ] suffix? is a mezzanine in reach versions of View. If the version you are using doesn't have, check the source ov View1.3 for the code. Sunanda

 [5/10] from: kpeters:vu-ware at: 25-Jun-2005 12:50

Newbie find question ctd....


Thanks= guys! So is this a bug then, or does '?' not= represent a single (character) entity as in most other languages/OSs I have= come across? &#160#160&#160;if find/match/any file= "p?.htm" [ &#160;&#160;&#160;&#160;print file= p1.htm p2.htm p3.htm p3.html.htm >> TIA, Kai

 [6/10] from: volker::nitsch::gmail::com at: 25-Jun-2005 23:30


No, "*?" are the wildcards in rebol too. But i have to correct me (there are lots of &#160 in the mail, that confused.) Short experiment:
>> find/match/any "p3.htm.html" "p?.htm"
== ".html" Oops, did not expect that. (Maybe not a bug, but a feature?) Lets check difference at start !>> find/match/any "ap3.htm.html" "p?.htm" == none At least this is ok. So /match does force a match at the beginning, but not at the end. Ok, then !>> tail? find/match/any "p3.htm.html" "p?.htm" == false !>> tail? find/match/any "p3.htm" "p?.htm" == true but if !>> tail? find/match/any "ap3.htm" "p?.htm" ** Script Error: tail? expected series argument of type: series port bitset ** Near: tail? find/match/any "ap3.htm" "p?.htm" So we have to adress that too: !>> all[pos: find/match/any "p3.htm.html" "p?.htm" tail? pos] == none !>> all[pos: find/match/any "p3.htm" "p?.htm" tail? pos] == true !>> all[pos: find/match/any "p3.htm" "ap?.htm" tail? pos] == none Not really nice, but seems to work. HTH Maybe On 6/25/05, Kai Peters <[kpeters--vu-ware--com]> wrote:
> Thanks= guys! So is this a bug then, or does '?' not= represent a single > (character) entity as in most other languages/OSs I have= come across?
<<quoted lines omitted: 4>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [7/10] from: antonr:lexicon at: 27-Jun-2005 19:06


Yes, these cases are handled by the test: %"" = find/any/match file pattern eg. foreach file [ %p1.htm %p2.htm %p33.htm %p.htm.000 ][ if %"" = find/any/match file "p?.htm" [print file] ] Anton.

 [8/10] from: sqlab:gmx at: 27-Jun-2005 15:06


how about find/match/any/tail
>> find/match/any/tail "p3.htm.html" "p?.htm"
== none
>> find/match/any/tail "p3.htm" "p?.htm"
== "p3.htm"
>>
AR Anton Rolls wrote:

 [9/10] from: antonr::lexicon::net at: 28-Jun-2005 1:12


Hmm, that seems to work.. It looks like a subtlety of /match is that /tail now forces a match to the tail of the series otherwise none is returned. It looks like a good feature, though it is not obvious from the inline help. Let me just say again that I am familiar for some years with the test: %"" = find/any/match file pattern and find/any/match/tail file pattern is probably a better replacement (but unproven to me yet). Anton.

 [10/10] from: volker::nitsch::gmail::com at: 28-Jun-2005 10:05


BTW, using [%"" = string] instead of [tail? string]. Thats a nice trick, never thought about it. Does an implicit none-check, sometimes handy. On 6/27/05, Anton Rolls <[antonr--lexicon--net]> wrote:
> Hmm, that seems to work.. > It looks like a subtlety of /match is that /tail
<<quoted lines omitted: 41>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted