【问题标题】:PHP RegEx in textarea文本区域中的 PHP 正则表达式
【发布时间】:2014-09-18 07:06:16
【问题描述】:

我在 textarea 中进行 reg 表达式检查时出现此警告。

警告:ereg(): REG_BADBR in contact/library.php

我的代码是

function validateMessage($message) {
    if(ereg('^[A-Za-z0-9[:punct:]]{2,300}$',$message)){
            return true;
    }
    else {
        return false;
    }
}

收到错误是因为我有错误的 ereg 还是因为它在 textarea 中?!

【问题讨论】:

  • 最好提供cmets,而不是只提供代码。

标签: php regex textarea


【解决方案1】:

ereg 已弃用,请改用preg_match

if(preg_match('/^[A-Za-z0-9[:punct:]]{2,300}$/',$message)){

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 2019-11-29
    • 1970-01-01
    相关资源
    最近更新 更多