【问题标题】:php/regex: allow dashes in this patternphp/regex: 在这种模式下允许破折号
【发布时间】:2009-04-21 21:29:37
【问题描述】:

我怎样才能在这种模式中允许破折号?

$str = preg_replace ( "/[^a-z \d]/i", "", $str ) ;

【问题讨论】:

    标签: php regex


    【解决方案1】:

    把它放在第一位。

    $str = preg_replace ( "/[^-a-z \d]/i", "", $str ) ;
    

    【讨论】:

      猜你喜欢
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多