So - I have strings like this (string1 examples):
'aaaaabbbbbcccccword'
'aaaaabbbbbcccccwor*d'
'aaaaabbbbbcccccw**ord*'
'aaaaabbbbbccccc*word*'
And I need to remove some substring (string2) from the end of those strings along with any * characters in string2 a well as * preceding string2 and following string2. string2 is some variable. I can't think of a regex that can be used here.
//wrong example, * that might happen to be inside of $string1 are not removed :(
$string1 = 'aaaaabbbbbcccccw**ord*';
$string2 = 'word';
$result = preg_replace('#\*?' . $string2 . '\*?$#', '', $string1);
Can someone suggest a PCRE regex for that?
P.S. Can I get upvoted to like at list 15 points? SO I can upvote people?