mercredi 7 décembre 2016

preg_match not reading results: Delimiter issue?

I have a part of a string. I need to check if it would equal another string when I add a few symbols on. However, my use of delimiters (I believe) is not allowing for the matches to take place.

My IF statement:

if (preg_match("{" . "$words[$counter_words]" . "[<]N}", "$corpus[$counter_corpus]")) 

My corpus:

{3(-)D[<]AN}
{dog[<]N}
{4(-)H(')er[<]N}
{4(-)H[<]A}
{A battery[<]h}

My partial array is as follows

dog
cat
3-D
plant

My goal is to match "dog" with "{dog[<]N}" (the [] and {} are delimiters). To try to compensate for this, I glue delimiters to the start and end of the string. Preg_match accepts it, but does not match the two together.

What would be the solution to this? I cannot find or think of a solution. Your help is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire