duanjiao8871 2012-10-31 04:50
浏览 66
已采纳

Php正则表达式preg_match重复字符

I have a string in php like this.

$string = "123451" 

which contains non-consecutive repeated characters of 1. How do i match the repeated characters using preg_match.

I browsed around and found preg_match('/(.)\1\1/', $string)) but it only works for repeated consecutive characters.

  • 写回答

1条回答 默认 最新

  • dongshi3605 2012-10-31 05:41
    关注

    What about something like

    (\d+).*\1
    

    If you get any match there is a repeated number.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 滑块验证码拖动问题悬赏
  • ¥15 Wanted but not invoked:Actually, there were zero interactions with this moc
  • ¥20 怎么驱动tb6612
  • ¥15 Arcgis 3D效果点要素
  • ¥15 在执行yolo训练脚本的时候,没有报错,在扫描val这一步后就推出执行了
  • ¥15 delphi开发的WEBSERVER改用HTTPS协议
  • ¥15 pic16f877A单片机的计数器proteus仿真失效
  • ¥100 调查 Vitis AI 中验证 .xmodel 量化后的正确性
  • ¥30 codelite全屏时file、setting那一行消失了
  • ¥15 gazebo-rviz教程