0

PHPで許可されていない文字を含む単語を強調表示する方法

以下は、文字列 $noticeText でエラーを見つけるためのコードです

function AddressOnlyValidatorNoticeTemp($str_fieldValue)
{
    $str_pattern = '/[^A-Za-z0-9 #.,:()%?!^[@\]*{}\/&_-\\s]/'; // 25-08-2010
    preg_match_all($str_pattern, $str_fieldValue,$matches);
    if($matches[0] != null)
    {
        $message = "Only 'A-Z a-z 0-9 # . , ( ) & % ? [ ] @ * { } _ / -' Characters Allowed";
    }
    else
    {
        $message = 1;
    }

    return $message;
}

if (!$errFlag)
{
    $errMsg = AddressOnlyValidatorNoticeTemp($noticeText);
    if ($errMsg != 1)
    {   
        $errMsg = "Notice Details : ".$errMsg;
        $errFlag = true;
    }
}

私の問題は、$str_pattern で許可されていない文字を含む単語を強調表示する方法です。

ありがとう

4

0 に答える 0