From what I can understand of your request:
You have a text file containing phrases.
You have a string of text from some source (onTEXT).
You want to match the lines in the text file to whatever your string is.
If this is correct..
My suggestion is to load the lines into a hash table with the item as the regex/wildcard you want to search, and the data as the line you want to display. A simple $replace can convert spaces/etc to * (wildcard) or .* (regex) in your table. Testing may be required to determine if one is quicker than the other. Example:
(regex)
(?i)^this.*is.*your.*first.*line$ = this is your first line
(wildcard)
this*is*your*first*line = this is your first line
etc.
Then you can do a $hfind search through the whole table for any/all matches.
%text = this298374is923847your982734first92374line
%item = $hfind(yourtable,%text,1,R)
%data = $hget(yourtable,%item)
(change R to W for wildcard match)
(example only)
-genius_at_work