How to remove the last word from the next line, that is, “dark pink”:
$str = 'Чехол Hoco Business Litchi для iPad 2/3/4 темно-розовый';
Or correct my version:
preg_replace('/^\s*((\S+[\s$]+){1,9}).*/', '\\1', $str);
How to remove the last word from the next line, that is, “dark pink”:
$str = 'Чехол Hoco Business Litchi для iPad 2/3/4 темно-розовый';
Or correct my version:
preg_replace('/^\s*((\S+[\s$]+){1,9}).*/', '\\1', $str);
Reply from comment.
To remove the last word in a line, it is logical to replace everything from the last space to the end of the line:
=\s\S+$=
Example:
$str = 'Чехол Hoco Business Litchi для iPad 2/3/4 темно-розовый'; $res = preg_replace('=\s\S+$=', '', $str); var_dump($res);
Fiddle: https://repl.it/CgKL .
Source: https://ru.stackoverflow.com/questions/263951/
All Articles