Since databases can build an index over the strings that works for simple regexes and shell-like glob patterns, of course such an algorithm exists. And since many databases are open source, you can just look at their implementation (for example mysql supports fulltext indexes and patterns that contain simple wildcards).
But you could just pull it all into a database, don't reinvent the wheel, drink a $beverage_of_your_choice and be happy.