Regular expression

I have 2 wild cards

  1. “PersonalBlue M.*Mat”
  2. “PersonalBlue M.*Copay.*Mat”

and both pattern are match with string “PersonalBlue M14P $3,500/80%; $35 Copay 4 Visits; 50% Rx w/Mat”


eregi(‘PersonalBlue M.*Mat’, ‘PersonalBlue M14P $3,500/80%; $35 Copay 4 Visits; 50% Rx w/Mat’, $matches);

eregi(‘PersonalBlue M.*Copay.*Mat’, ‘PersonalBlue M14P $3,500/80%; $35 Copay 4 Visits; 50% Rx w/Mat’, $matches2);

echo “<br>”;
echo strlen ($matches[0]);
echo “<br>”;
echo strlen ($matches2[0]);


The length of matched string is same for both. I need the first wild card should match with the string “PersonalBlue M09P $2,500/80%; 50% Rx w/Mat” but not with the “PersonalBlue M14P $3,500/80%; $35 Copay 4 Visits; 50% Rx w/Mat”.

What will be the appropriate first wild card?

eregi is deprecated; use preg_match instead.

As for your mask matching, a negated subpattern on Copay in the first pattern will prevent it from matching.

will you give an example of pattern?

Off Topic:

(Why am I answering all the PREG questions this week? Masochist i swear. I dont even know PREG very well)

‘/PersonalBlue M.*(!Copay).*Mat/’

thanks for posting. but this pattern “PersonalBlue M.*(!Copay).*Mat” does not match with ‘PersonalBlue M09P $2,500/80%; 50% Rx w/Mat’