"FindText" Action Block

Dm114

Well-known member
Finds all occurrences of a string in a list or a text line by line (like a ".TXT" file). Search can be case sensitive or not.

INPUT variables:
SourceText: string containing the original text to browse
StringToSearch: string containing the piece of text or characters to be searched for (can be any combination of any kind of character or emoji)
CaseSensitive: boolean indicator to make search case sensitive. Default: False=case INsensitive
RegexExcl: optional string to skip line headers (i.e. this pattern at the beginning of each line won't be included in the search process). This string must follow Regex rules.

OUTPUT variable:
FoundText: string filled with all lines containing the searched string. Empty if no match found.

The macro "Tst🔍" is provided to illustrate how "FindText" Action Block works to find any character or string in a text. As an example, the original text here is a list of local TV channels.


Enjoy!
 

Dm114

Well-known member
I updated the Action Block because it didn't recognize Carriage Return as an End Of Line in the SourceText input variable.
 

Dm114

Well-known member
Finds all occurrences of a string in a list or a text line by line (like a ".TXT" file). Search can be case sensitive or not.

INPUT variables:
SourceText: string containing the original text to browse
StringToSearch: string containing the piece of text or characters to be searched for (can be any combination of any kind of character or emoji)
CaseSensitive: boolean indicator to make search case sensitive. Default: False=case INsensitive
RegexExcl: optional string to skip line headers (i.e. this pattern at the beginning of each line won't be included in the search process). This string must follow Regex rules.

OUTPUT variable:
FoundText: string filled with all lines containing the searched string. Empty if no match found.

The macro "Tst🔍" is provided to illustrate how "FindText" Action Block works to find any character or string in a text. As an example, the original text here is a list of local TV channels.


Enjoy!
It's now possible to make a string search on an array (see updated description in "FindText" Action Block).

A new output variable has been added as follows:

OUTPUT variables (only one of them is mandatory):
• FoundText: string filled with all lines containing the searched string. Empty if no match found
FoundArray
: array containing all matched lines. Each line stored in the array items from index 0 to N. Empty if no match found.

💡 Input "SourceText" can contain an array. To exclude index numbers (of the form "[index]: ") from search process, set "RegexExcl" to "\[\d+\]:\s". Otherwise, if "StringToSearch" contains only digits or a string of the "[n]: " form, indexes will be included in the search process.
 
Top