Skip to content

Commit e84a550

Browse files
authored
Merge pull request #27 from ws-garcia/Support-for-LIKE-($)-operator
Support for like ($) operator
2 parents 5fbd8e4 + 3496143 commit e84a550

File tree

4 files changed

+164
-225
lines changed

4 files changed

+164
-225
lines changed

docs/api/methods/filter.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ The `Pattern` parameter is evaluated according to the number of records in the C
6060
* To reference a field value, the user must type something like `f#` where `f` is a required identifier and `#` is the numeric position of the desired field. For example, `f1>5` indicates the selection of records whose first field value is greater than `5`.
6161
* If the user needs to compare literal strings, the values must be enclosed in apostrophes. Example, `Region = 'Central America'` is a valid string assigned to the variable `Region`.
6262
* User can use functions in the `Pattern` definition, including custom UDFs (refer to [VBAexpressions documentation](https://github.com/ws-garcia/VBA-Expressions)). I.e.: `min(f5;f2)>=100`
63+
* The LIKE operator (`$`) comparison is influenced by the `Option Compare` statement (one of: `Option Compare Binary` or `Option Compare Text`). The binary compare is case sensitive, the text compare is not. The following table describes the special characters to be used when creating patterns; all other characters match themselves:
64+
*
65+
|Character|Meaning|
66+
|:------:|:-----|
67+
|?|Any single character|
68+
|\*|Zero or more characters|
69+
|#|Any single digit (0-9)|
70+
|\[list\]|Any single character in list|
71+
|\[!list\]|Any single character not in list|
72+
|\[\]|A zero-length string ("")|
73+
* 'list' matches a group of characters in `patterns` to a single character in the string and can contain almost all available characters, including digits.
74+
* Use a hyphen (-) in 'list' to create a range of characters that matches a character in the string: e.g. [A-D] matches A,B,C, or D at that character position in the string. Multiple ranges of characters can be included in 'list' without the use of a delimiter: e.g. \[A-DJ-L\].
75+
* Use the hyphen at the start or end of 'list' to match to itself. For example, \[-A-G\] matches a hyphen or any character from A to G.
76+
* The exclamation mark in the "pattern" match is similar to the negation operator. For example, [!A-G] matches all characters except characters A through G.
77+
* The exclamation mark outside the bracket matches itself.
78+
* To use any special character as a matching character, enclose the special character in brackets. For example, to match a question mark, use \[?\].
6379

6480
When the `FilePath` argument is omitted, the method will proceed to filter the data stored in the current instance, otherwise it will filter the content of the CSV file specified with the referred argument.
6581

@@ -76,8 +92,8 @@ Sub FilterCSV()
7692
CSVint.parseConfig.Headers = False 'The file has no header record/row
7793
CSVint.parseConfig.path = path
7894
If path <> vbNullString Then
79-
Set FilteredData = CSVint.Filter("f1='Asia' & f9>20 & f9<=50", path) 'Select "Units sold" greater than 20 and less or
80-
'equal to 50 from Asian customers
95+
Set FilteredData = CSVint.Filter("f1='Asia' & f9>20 & f9<=50 & f8 $ '10/*/2014'", path) 'Select "Units sold" greater than 20 and less or
96+
'equal to 50 from Asian customers in October 2014
8197
Set CSVint = Nothing
8298
Set FilteredData = Nothing
8399
End If

docs/api/methods/filter2.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)