I have a requirement for a service that does the following.
Take a block of text and identify the server names in it (by name or ip address). So given:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero felis, accumsan in nunc id, lacinia rutrum libero. Server1 Praesent iaculis consequat est quis elementum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos Server2 himenaeos. Cras aliquet nisl non tortor interdum semper. Nulla commodo dignissim justo, eu accumsan neque eleifend ut. Etiam malesuada volutpat dolor 192.168.0.2 laoreet placerat. Maecenas posuere ipsum mattis egestas elementum.
The service would return:
- Server1
- Server2
- Server3 (which has ip Address 192.168.0.2)
there are around 7,000 servers and addresses in my DB. So at the moment the only strategy I have is to take the text block as a string and loop through all the servers twice (name and ip) issuing a string.Contains().
Issuing 14,000 Contains seems a bit "brute force". Is there a more elegant way to achieve the same result.
For context this is a rest service running on ASP.Net MVC and C#.