dqef7931 2013-03-29 14:25
浏览 107
已采纳

PHP正则表达式 - 如果自定义标点符号是并排的,则正则表达式不匹配

my regexp

/^[\p{L}\p{N}][\p{L}\p{N} \.,;:\?!-“”‘’"']+$/u

aim of regexp

allow utf-8 characters, numbers, spaces AND custom punctuation to verify article title

these inputs below don't match but I want matching also if punctuation are side-by side? Can you show me the correct form of my regexp? note: Backslash in front of dot and question mark are for escaping attempt. I also tried without escaping. I am not good at regexp. I can only find sub-parts then try to combine. thanks. BR

inputs that don't match

  1. "Selim"!'"':?-
  2. "'
  3. '"
  4. ?!
  5. I also discovered that I can not start with punctuation to a title. example "title" Day doesn't match
  • 写回答

2条回答 默认 最新

  • duanfen2349 2013-03-29 14:39
    关注

    change with:

    /^[\p{L}\p{N}“”‘’"'][\p{L}\p{N} .,;:?!\-“”‘’"']*$/u
    

    NB: - must be escaped if it isn't in the first or last position within the character class. But . and ? doesn't need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集