היי, אני מנסה לעשות ביטוי רגולרי שיקבל טקסט משהו כזה:
slim
my asd
my fasdfadsf
is sadfsdf
is good
אני רוצה שזה ימחוק כל פעם את מה שבין המילה my למילה is כולל אותם, אחרי פעם אחת זה יהיה:
slim
my asd sadfsdf
is good
ואחרי פעמיים של הpreg_replace זה יהיה:
slim good
אני בטוח שזה אפשרי ואמור להיות די פשוט אבל ניסיתי את זה ומשום מה זה לא עובד:
קוד:
$text = "slim my asd my fasdfadsf is sadfsdf is good";
$regex = '/^(my).+(is)$>/i';
while(preg_match($regex, $text))
{
preg_replace($regex, '', $text);
}
echo $text;
יש למישהו רעיון?