Automatically generating Regex from set of strings residing in DB C#

Posted by Muhammad Adeel Zahid on Stack Overflow See other posts from Stack Overflow or by Muhammad Adeel Zahid
Published on 2010-05-28T16:57:23Z Indexed on 2010/05/28 17:02 UTC
Read the original article Hit count: 444

Filed under:
|

Hello Everyone

i have about 100,000 strings in database and i want to if there is a way to automatically generate regex pattern from these strings. all of them are alphabetic strings and use set of alphabets from English letters. (X,W,V) is not used for example. is there any function or library that can help me achieve this target in C#. Example Strings are

KHTK
RAZ

given these two strings my target is to generate a regex that allows patterns like (k, kh, kht,khtk, r, ra, raz ) case insensitive of course. i have downloaded and used some C# applications that help in generating regex but that is not useful in my scenario because i want a process in which i sequentially read strings from db and add rules to regex so this regex could be reused later in the application or saved on the disk. i m new to regex patterns and don't know if the thing i m asking is even possible or not. if it is not possible please suggest me some alternate approach.

Any help and suggestions are highly appreciated.
regards
Adeel Zahid

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex