问题
I have a test like
LEFT('F13',2)='F1'
I want to change it from a left-side match to a test that supports wildcards
'F13'='F?3'
Excel doesn't support regex except in VBA code but i'd prefer this was done in a macro. I should point out that the actual test isn't a simple string, but cell references (this may be important, I'm not sure):
IF(LEFT($DATA.$A$2:$A$1501,LEN($B$3))=$B$3,...
The range actually evaluates to a single cell based on where the macro is called from. $B$3 is the pattern input by the user.
回答1:
=SEARCH("F?3","F13")=1
In your second example, if B3 contains wildcards infused text
=SEARCH(B3,$DATA.$A$2:$A$1501)=1
SEARCH returns the position where it finds the first argument. The "=1" ensures the string starts with the first argument as opposed to somewhere in the middle. I'm not sure how your $DATA argument works, so I just copied it verbatim.
来源:https://stackoverflow.com/questions/1242677/how-to-match-a-string-wildcard-pattern-in-an-excel-macro