<bdo id='MvbZM'></bdo><ul id='MvbZM'></ul>
<legend id='MvbZM'><style id='MvbZM'><dir id='MvbZM'><q id='MvbZM'></q></dir></style></legend>

<small id='MvbZM'></small><noframes id='MvbZM'>

    <i id='MvbZM'><tr id='MvbZM'><dt id='MvbZM'><q id='MvbZM'><span id='MvbZM'><b id='MvbZM'><form id='MvbZM'><ins id='MvbZM'></ins><ul id='MvbZM'></ul><sub id='MvbZM'></sub></form><legend id='MvbZM'></legend><bdo id='MvbZM'><pre id='MvbZM'><center id='MvbZM'></center></pre></bdo></b><th id='MvbZM'></th></span></q></dt></tr></i><div id='MvbZM'><tfoot id='MvbZM'></tfoot><dl id='MvbZM'><fieldset id='MvbZM'></fieldset></dl></div>
    <tfoot id='MvbZM'></tfoot>

      1. PHP 正则表达式中的 UTF-8

        时间:2023-10-03
        <tfoot id='lllrh'></tfoot>

                  <tbody id='lllrh'></tbody>
                  <bdo id='lllrh'></bdo><ul id='lllrh'></ul>

                • <i id='lllrh'><tr id='lllrh'><dt id='lllrh'><q id='lllrh'><span id='lllrh'><b id='lllrh'><form id='lllrh'><ins id='lllrh'></ins><ul id='lllrh'></ul><sub id='lllrh'></sub></form><legend id='lllrh'></legend><bdo id='lllrh'><pre id='lllrh'><center id='lllrh'></center></pre></bdo></b><th id='lllrh'></th></span></q></dt></tr></i><div id='lllrh'><tfoot id='lllrh'></tfoot><dl id='lllrh'><fieldset id='lllrh'></fieldset></dl></div>

                  <small id='lllrh'></small><noframes id='lllrh'>

                • <legend id='lllrh'><style id='lllrh'><dir id='lllrh'><q id='lllrh'></q></dir></style></legend>
                  本文介绍了PHP 正则表达式中的 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要正则表达式方面的帮助.我的字符串包含 unicode 字符,下面的代码不起作用.

                  I need help with regular expressions. My string contains unicode characters and code below doesn't work.

                  前四个字符必须是数字,然后是逗号,然后是任何字母字符或空格...我已经读过,如果我在常规表达式的末尾添加/u 但它对我不起作用...

                  First four characters must be numbers, then comma and then any alphabetic characters or whitespaces... I already read that if i add /u on end of regular expresion but it didn't work for me...

                  我的代码适用于非 unicode 字符

                  My code works with non-unicode characters

                  $post = '9999,škofja loka';;
                  echo preg_match('/^[0-9]{4},[s]*[a-zA-Z]+', $post);
                  

                  感谢您的回答!

                  推荐答案

                  更新答案:
                  这是现在测试和工作

                  Updated answer:
                  This is now tested and working

                  $post = '9999, škofja loka';
                  echo preg_match('/^\d{4},[\s\p{L}]+$/u', $post);
                  

                  \w 将不起作用,因为它不包含所有 unicode 字母,并且除了字母之外还包含 [0-9_].

                  \w will not work, because it does not contain all unicode letters and contains also [0-9_] additionally to the letters.

                  重要的还有 u 修饰符来激活 unicode 模式.

                  Important is also the u modifier to activate the unicode mode.

                  如果逗号后可以有字母 空格,那么您应该将它们放入相同的字符类中,在您的正则表达式中,逗号后有 0 个或多个空格,然后只有字母.

                  If there can be letters or whitespace after the comma then you should put those into the same character class, in your regex there are 0 or more whitespace after the comma and then there are only letters.

                  参见http://www.regular-expressions.info/php.html用于 php 正则表达式的详细信息

                  See http://www.regular-expressions.info/php.html for php regex details

                  \p{L}(Unicode 字母)解释 这里

                  The \p{L} (Unicode letter) is explained here

                  重要的还有使用字符串边界的结尾 $ 来确保真正完整的字符串被验证,否则它只会匹配第一个空格而忽略其余的例如.

                  Important is also the use of the end of string boundary $ to ensure that really the complete string is verified, otherwise it will match only the first whitespace and ignore the rest for example.

                  这篇关于PHP 正则表达式中的 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:mySQL 表中的重音字符 下一篇:使用 GD ( imagettftext() ) 和 UTF-8 字符

                  相关文章

                  最新文章

                • <legend id='pd7aW'><style id='pd7aW'><dir id='pd7aW'><q id='pd7aW'></q></dir></style></legend>
                  <i id='pd7aW'><tr id='pd7aW'><dt id='pd7aW'><q id='pd7aW'><span id='pd7aW'><b id='pd7aW'><form id='pd7aW'><ins id='pd7aW'></ins><ul id='pd7aW'></ul><sub id='pd7aW'></sub></form><legend id='pd7aW'></legend><bdo id='pd7aW'><pre id='pd7aW'><center id='pd7aW'></center></pre></bdo></b><th id='pd7aW'></th></span></q></dt></tr></i><div id='pd7aW'><tfoot id='pd7aW'></tfoot><dl id='pd7aW'><fieldset id='pd7aW'></fieldset></dl></div>

                    <tfoot id='pd7aW'></tfoot>
                        <bdo id='pd7aW'></bdo><ul id='pd7aW'></ul>

                    1. <small id='pd7aW'></small><noframes id='pd7aW'>