How to get a Specific string from an array

Suppose if you want to get a specific string within an array that you don’t know on which position it is located,in this case we can go for filter condition.

Filter function help you to filter a specific sub string in a string

Return Value:

Returns a zero-based array containing a subset of a string array based on a specified filter criteria.

Filter(InputStrings, Value[, Include[, Compare]])
Arguments:
InputStrings :
Required. One-dimensional array of strings to be searched. 
Value :
Required. String to search for. 
Include :
Optional. Boolean value indicating whether to return substrings that include  or exclude Value. If Include is True, Filter returns  the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of the array that does not  contain Value as a substring. 
Compare :
Optional. Numeric/Text comparision
Example:
Dim MyIndex
Dim MyArray (3)
MyArray(0) = "Sunday"
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyIndex = Filter(MyArray, "Mon") ' MyIndex(0) contains "Monday".
Remarks:If no matches of Value are found within InputStrings,  Filter returns an empty array. An error occurs if InputStrings is  Null or is not a one-dimensional array.
The array returned by the Filter function contains only enough  elements to contain the number of matched items.
Thanks,
Chinnu

Advertisement
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.