I think you should use a hash table for this. A regular expression for this situation would be cumbersome and computationally expensive compared to a simple hash table. A hash table is an associative array that holds key-value pairs. You can match a key (a string, in your example) to a number (the number of times it's appeared in the input next). Simply place all of the strings from your database into the hash table as keys with values of zero. Check every string in the input text to see if it's in the hash table. If it is, increment the value, if not, do nothing. C++, Java, C#, Python and most other general purpose languages have an implementation of the hash table. I wrote a simple program in C++ which demonstrates this capability:
#include<iostream>
#include<unordered_map>
#include<string>
#include<fstream>
int main()
{
std::unordered_map<std::string, int> map;
std::ifstream matches("matches.txt");
std::ifstream input("input.txt");
std::string in;
while(matches>>in){
map[in] = 0;
}
while(input>>in){
if(map.find(in) != map.end())
++map[in];
}
for(auto i : map)
std::cout<<i.first<<" "<<i.second<<std::endl;
return 0;
}
This C++ code creates a hash table (called an unordered_map). It then reads in "matches", which represents the patters from your DB, and adds them to the table with initial keys of zero. It reads in inputs from the "inputs" stream, and checks to see if they are in the hash table. If they are, it increments the key value. Then the program prints the elements of the table with the number each appears in key-value order.