I have a file with many records. Fields are delimited by tab. One of the fields is a list of comma separated keywords. What I want is to extract only those records that have keywords according to an expression given on runtime.
Is there a package available that can create a single regular expression starting from a string like the following ones?
moe&(shemp|curly|joe)&larry (tom&jerry)|(sylvester&tweety)
If I have to do that by myself, I can manage the ORs with something like this in the regex:
\b(one|two|three)\b
but I'm not sure how to handle the ANDs. I've done some tests with advanced expressions like (?=word) without understanding what is really going on.
I also thought on sorting each keywords list to allow simple regex being written as \bone\b.*\btwo\b, but is useless if I want to search for:
olive&(popeye|bluto)
Hints, please?
In reply to AND and OR on Regular Expressions by vitoco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |