doujing2497 2018-05-07 01:28
浏览 61
已采纳

允许在PHP中使用英语和俄语字符集的正则表达式[重复]

This question already has an answer here:

I have a contact form that is translated in both English and Russian. My client wants to be able to type Russian characters into the form fields as well as English. I am not great at regex and am hoping someone can help me adjust the regex I'm using to allow for the extra character set. I've already tried several different options I've found on here and none of them seem to be working. Which most likely means I'm not using it correctly. I'm using PHP and this is the regex for the first form input.

'/^[a-z][a-z ]*$/i'

I've tried it like this:

'/^[a-z][a-z ][\x{0410}-\x{042F}]*$/i'
'/^[a-z][a-z ][А-Яа-яЁё]*$/i'
'/^[a-z][a-z ][\p{Cyrillic}]*$/i'

But none of them seem to work.

</div>
  • 写回答

2条回答 默认 最新

  • dozr162106 2018-05-07 01:46
    关注

    Maybe because you didn't put them in the same bracket?

    (and the other question mentions the u flag)

    '/^[a-z][a-z А-Яа-яЁё]*$/iu'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)