The financial auditors in my office needed a way to search for a variety of keywords in a field of a dataset. The needed different keywords for different tests. They also wanted to see which keyword matched in its own column.
#Contains_Keyword_File( SEARCHFIELD, "filename.txt" )
This function searches the SEARCHFIELD for any keyword in the supplied file and returns the keyword that was found, or an empty string is nothing was found. The text file should contain one keyword per line. The search is case insensitive. The search locates substrings, so searching for "app" will match on "happiness" in the data.
IDEA will look for the file in the current project folder. If you want to locate the file elsewhere, add a path to the filename parameter. Example:
#Contains_Keyword_File( SEARCHFIELD, "Other.ILB\filename.txt" )
I'm not thrilled that the code has to open and close the keyword file everytime the function is invoked, but I've not found a mechanism in IDEA where I might be able to load the keywords into a cache that persists between function calls. Suggestions are welcome.
This function was partially inspired by the "Text Search" script found elsewhere on this site.
Last seen: 2 years 9 months ago
Joined: 10/04/2017 - 10:58