- These are my 2 best solutions at present, please be mature about any feedback.
- If you specify 1 needle for contains/in, it should be relatively easy to add a 2nd needle without rewriting everything.
Code: Select all
;IDEA 1: xxxC/xxxP operators
if (var contains StrSplit("abc,def,ghi", ",")) ;we need *SOMETHING* better than this
if (var contains "item1,item1ctd,item1ctd") ;1 item
if (var containsC "item1,item2,item3") ;3 items (no special ',,' handling)
if (var containsP "item1|item2|item3") ;3 items (no special '||' handling)
;contains, containsC, containsP
;in, inC, inP
;starts, startsC, startsP ;potentially
;ends, endsC, endsP ;potentially
;note: the xxxP operators are useful for needles that contain commas and for conversion to/from ~= (RegExMatch)
;==================================================
;IDEA 2: StrSplit comma/pipe unary operators
if (var contains StrSplit("abc,def,ghi", ",")) ;we need *SOMETHING* better than this
if (var contains "item1,item1ctd,item1ctd") ;1 item
if (var contains splitc "item1,item2,item3") ;3 items (no special ',,' handling)
if (var contains splitp "item1|item2|item3") ;3 items (no special '||' handling)
;note: perhaps a 'split' or 'splitx' operator would split every character (n-length string to n-length array)
;note: alternatively/additionally, a binary operator: "a,b,c" split "," [although this puts the operator after the string, where it's less visible, and easy to miss]
;[EDIT:] if (var contains "abc,def,ghi" split ",") [not great, less clear than StrSplit()]