This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
fs.find wildcards
Started by apemanzilla, 14 April 2014 - 04:27 PMPosted 14 April 2014 - 06:27 PM
Could anyone provide a list of acceptable patterns and wildcards for use with fs.find? I'm making a pure-Lua implementation of it for one of my projects. All I could find so far was the '*' wildcard.
Posted 14 April 2014 - 07:40 PM
I don't think there are any others since none are documented on the wiki besides from the asterisk. I have the source in front of me.. but I don't know how regexes work (should I be ashamed?). And I'm assuming it wouldn't be okay to post the source here for someone that understands them to decipher, so I won't.
Posted 14 April 2014 - 07:54 PM
Well I just tested and ? seems to work too…I don't think there are any others since none are documented on the wiki besides from the asterisk. I have the source in front of me.. but I don't know how regexes work (should I be ashamed?). And I'm assuming it wouldn't be okay to post the source here for someone that understands them to decipher, so I won't.
fs.find("rom/????/gps") finds rom/apis/gps and rom/help/gps…
Edited on 14 April 2014 - 05:55 PM
Posted 14 April 2014 - 07:59 PM
Pure guessing here but it would make sense
* - one or more wildcards
? - one wildcard
Wonder if there are other unknown ones.
* - one or more wildcards
? - one wildcard
Wonder if there are other unknown ones.
Edited on 14 April 2014 - 05:59 PM
Posted 14 April 2014 - 08:00 PM
Those two are correct, but I'm still trying to see if there are others.Pure guessing here but it would make sense
* - one or more wildcards
? - one wildcard
Wonder if there are other unknown ones.
Posted 14 April 2014 - 08:02 PM
'.' seems to do the same as '?'.
EDIT: There's a Lua implementation of the function in Gamax's version of cclite here on line 687.'?', '.' and '*' seem to be all of them.
EDIT: There's a Lua implementation of the function in Gamax's version of cclite here on line 687.
Edited on 14 April 2014 - 06:09 PM
Posted 14 April 2014 - 08:04 PM
Could someone try '-'? On my iPad right now.'.' seems to do the same as '?'.
Posted 14 April 2014 - 08:09 PM
Could someone try '-'? On my iPad right now.
I've created three files in root named '1', '2' and '3'.
fs.find("[1-3]")
seems to find all of them.
Edited on 14 April 2014 - 06:10 PM
Posted 14 April 2014 - 08:29 PM
So I guess it's using string patterns…Could someone try '-'? On my iPad right now.
I've created three files in root named '1', '2' and '3'.fs.find("[1-3]")
seems to find all of them.
Try the same three files and fs.find("%d") please? :P/>
Edited on 14 April 2014 - 06:29 PM
Posted 14 April 2014 - 08:41 PM
So I guess it's using string patterns…
Try the same three files and fs.find("%d") please? :P/>
Yes, it seems to find all three of them.
Posted 14 April 2014 - 08:44 PM
For whatever reason none of them work for me. Only the asterisk (*). But if I'm correct I would say here is a list of what should work.
Posted 14 April 2014 - 09:22 PM
That's probably the case since Pattern.compile is what the source code uses.For whatever reason none of them work for me. Only the asterisk (*). But if I'm correct I would say here is a list of what should work.
Posted 14 April 2014 - 09:23 PM
Anyone knows why nothing works for me? I'm using CC 1.62.
Posted 14 April 2014 - 10:04 PM
They only seem to work on cclite. I can't use them on CC1.62 either.Anyone knows why nothing works for me? I'm using CC 1.62.
Posted 14 April 2014 - 10:06 PM
Interesting. I'll test more out later.They only seem to work on cclite. I can't use them on CC1.62 either.Anyone knows why nothing works for me? I'm using CC 1.62.
Posted 14 April 2014 - 10:10 PM
They only seem to work on cclite. I can't use them on CC1.62 either.Anyone knows why nothing works for me? I'm using CC 1.62.
Ah, well that would explain everything :D/>. I thought it was something wrong with my Java. That's why I use MC with real CC to test things. cclite's implementation uses regular Lua's string matching capabilities, so any Lua patterns would work.
Posted 15 April 2014 - 02:55 PM
Alright, in further testing it appears that in regular CC, only the * wildcard is accepted. Others may be available in emulators.