私はひもを持っています。PHP (および最も簡単なソリューション、おそらく preg_replace) を使用して、次のことを行います。
文字列から最後の 5 文字 (単語ではない) を見つけます。
これらの最後の 5 文字の 1 つに「&」文字が含まれている場合、この & 文字とそれに続くその他の文字を削除したいと考えています。
たとえば、文字列が次の場合:
$string='Hello world this day and tomorrow';
スクリプトは次を見つける必要があります:
' orrow
';
(「orrow」には「&」が含まれていないため、何もしません)。
でもいつ:
$string='Hello world this day and tomor &row';
また
$string='Hello world this day and tomo &rrow';
また
$string='Hello world this day and tomorrow &';
また
$string='Hello world this day and tomorrow&q';
また
$string='Hello world this day and tomorrow &co';
スクリプトは、& の後のすべての文字 (& を含む) を削除する必要があります。