Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用空格和连字符修剪字符串
$str = mb_ereg_replace("^([ \-]+)|([ \-]+)$", "", $str);
对于英文文本来说还不错。但是当俄语出现时,问题突然出现了:最后一个符号——无论是连字符还是空格——似乎都没有被删除。这仅对以俄语符号结尾的文本有效:
наркоман штоле --- -– 附近的空间е将保留;
наркоман штоле --- -
е
наркоман штоле? lol u mad --- -– 修剪成功。
наркоман штоле? lol u mad --- -
发生了什么?