jeudi 1 février 2018

rexex 'list of words' and 'list of word'

I'm developing a software that have to check if a text contains a word taken from a specified list and a word take from another specified list.

Example:

list 1: dog, cat
list 2: house, tree

the following texts has to match:

the dog is in the house -> contains dog and house
my house is full of dogs -> contains dog and house
the cat is on the tree -> contains cat and tree

the following has not to match

the frog is in the house -> there is no word from the first list
Boby is the name of my dog -> there is no word from the second list
Outside my house there is a tree -> there is no word from the first list

To solve quickly the problem I've made a list of pattern like:

dog.*house, house.*dog, cat.*house, ...

but I'm pretty sure there is an smarter way...

Aucun commentaire:

Enregistrer un commentaire