I explain my question by one example:
Example:
(English version)
$str = '1 healthy, fine, sound 2 tip-top, fit, robust, sturdy & 1 substandard, poor';
I want this output:
- healthy, fine, sound
- tip-top, fit, robust, sturdy
&
- substandard, poor
(Persian version) - It starts from the right
$str ='1 خشكاندن، خشكانيدن 2رطوبتزدايي كردن، نمزدايي كردن & تر کردن';
I want this output:
- خشكاندن، خشكانيدن
- رطوبتزدايي كردن، نمزدايي كردن
&
تر کردن
I know, 1 in this example is really vague. But actually it is the first character in the right. But in SO, because there isn't a proper direction for Persian, 1 goes in the left.
Note: Perhaps there are no numbers or even no &. In this case I don't want any change ..!
$str = 'healthy, fine, sound, tip-top'; // I want this: healthy, fine, sound, tip-top
$str = 'healthy, fine, sound & poor'; /* I want this: healthy, fine, sound
&
poor
*/
I can do that using multiple str_replace(). But I want to know, is it possible to I do that using REGEX?