|
|
|||||||
Ascan is limited to exact searches within a array. I think it would be useful to have an optional mode which allows you to do an "in-exact" search, much like the way Excel's find does it. I dug around to see if anyone has requested this and about the only thing I found was this thread. |
||||||||
|
|
|||||||
Ainstr()? right? a instr that is capable of searching array? and actually would work kinda as: instr(join($array,"*")) ja, I've missed that functionality sometimes. what I would want to be enhanced too is the capability for ascan() to return all matches at once in KiXtart array. |
||||||||
|
|
|||||||
InArray() perhaps. |
||||||||
|
|
|||||||
InArray() or Ainst() would be fine, but my thought was to just add an optional parameter to Ascan($array, $findstr, $start, $length, $Exact/In-exactMode). |
||||||||
|
|
|||||||
I don't like the idea of having multiple optional parameters. |
||||||||
|
|
|||||||
I don't like the ainst() (or ainstr()) name though. AFAIK "InStr" is short for "In String" so then "ainstr" would be what, "Array In String"? I have no issue with adding a partial match parm but think it should go beyond that. Maybe here would be a good place to get regular expressions introduced. The optional parm for AScan() could be a regular expression. |
||||||||
|
|
|||||||
no. I understand that at some point and some place regExp engine for kixtart is introduced but this surely is not the place. |
||||||||
|
|
|||||||
So what's wrong with multiple optional args? I mean its not like this would be the first time its ever been done. |
||||||||
|
|
|||||||
too confusing. |
||||||||
|
|
|||||||
LOL! Come on...If anyone can make it through Messagebox(), I think they might be able figure this one out too. |
||||||||
|
|
|||||||
Following on from Lonk's suggestion, here's a UDF to do the job. Note, no type checking of variables, use the optional delimiter if you have @CRLFs in the data. Code: Function udfStrInArray($aArray,$sSearch,Optional $sDelimiter) This returns the array element that the (sub)string was found in, or "-1" if not found. |
||||||||
|
|
|||||||
What if Code:
Anyway, all respect for the UDF |
||||||||
|
|
|||||||
well... if instr can find a number in integer value, then the udf can too. |
||||||||
|
|
|||||||
Mmm, can someone please post a clear example of the functionality that you are looking for here? What exactly is an 'inexact search'? Ruud |
||||||||
|
|
|||||||
someone may correct me but. it's basically a instr() on each array element. if array has: $array = "ruud","les","jokeli" this new functionality, say inArray(), would return on: inArray($array,"e") 1, as it's the first element where "e" is present. hope that's clean enough |
||||||||
|
|
|||||||
Sent Al a PM to check back here and provide a better example of what he's looking for. Not sure if he wants it to be "Fuzzy" search or what. |
||||||||
|
|
|||||||
My guess is he wants a substring match without any fuzz. I still think, since we have it cut open on the table, to add support for wildcards with regular expressions. |
||||||||
|
|
|||||||
so, to use regular expressions in kix, the data needs to be built inside array and then queried via ascan? doh. |
||||||||
|
|
|||||||
Eh, that is NOT what I said! Regular expressions could be added to other commands/functions as well. |
||||||||
|
|
|||||||
Lonks example is correct... and just for more info... $array="YYYY","MM","DD" $=ascan($array,"Y") $ would equal -1 right now because there is no value "Y" in the array. With the fuzzy/in-exact results $ would return 0. Does this help? |
||||||||
|
|
|||||||
Ok, I understand now and have added this functionality (i.e.: the option to have AScan do an InStr instead of an exact match) to beta 1 of 4.51. The beta is on its way to the download sites as I type this... Ruud |
||||||||
|
|
|||||||
Password protected tokenized files .... very nice ;0) |
||||||||
|
|
|||||||
Great! Thanks Ruud. |
||||||||
|
|
|||||||
Hey Richard... I somehow overlooked the UDF you posted. Thanks for putting that together... but since its in ascan now, I'll probably never get to use it... |
||||||||
|
|
|||||||
lol. but that UDF indeed was nice. I was too lazy to wrap it up but richie came and conquered |