Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在删除其他标点符号的同时保留音译中的点(.)?_Php_Punctuation_Transliteration - Fatal编程技术网

Php 如何在删除其他标点符号的同时保留音译中的点(.)?

Php 如何在删除其他标点符号的同时保留音译中的点(.)?,php,punctuation,transliteration,Php,Punctuation,Transliteration,我的以下功能用于清理上载的文件: public static function slugify($string) { $string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string); $string = preg_replace('/[-\s]+/', '-', $

我的以下功能用于清理上载的文件:

public static function slugify($string) {
        $string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
        $string = preg_replace('/[-\s]+/', '-', $string);
        return trim($string, '-');
    }

这里我有
[:标点:
来删除puctuations。问题是我想在文件名中保留点(.),因为当我删除它时,slugify会将
1.zip
转换为
1zip
。有没有办法使用此函数保留点?

您需要提供接受字符的列表。这:

$trans = Transliterator::create( "Latin; NFKD; [^\u0041-\u007A\u0020\u0027\u002D\002E] Remove; NFC" );
将删除除拉丁字母和['-.]以外的所有内容


您可能需要调整您的请求。您需要使用的代码是UTF-16。e、 “0x002E”是“.”

所以我应该找到相应的utf-16字符作为标点符号?是这样吗?如上例所示,方括号将采用UTF-16符号字符的列表或范围(\u0041-\u007A)。任何不匹配的内容都将被删除。因为我不知道你到底想用哪一个,所以我不能提供一个具体的片段。我使用Ubuntu中的字符表来获取代码\002E是句号。您的示例中有一个错误:将
\002E
更改为
\u002E