WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Preg_match not returning error? (3 posts)

  1. halben
    Member
    Posted 10 months ago #

    I was wondering if I could use preg_match in wordpress. I'm trying to validate a phone number and here is what I have:

    if (preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/", $sanitized_phone))
    			$errors[] = 'Error: Please enter a valid phone number. (e.g. 999-999-9999)';

    I tested it and there's not error output. Anyone know why?

  2. esmi
    Forum Moderator
    Posted 10 months ago #

    My guess is that the issue is either on your reg exp or with the placement of the code in a larger script. WordPress uses standard PHP. so there is no reason why you can't use preg_match().

  3. halben
    Member
    Posted 10 months ago #

    I figured it out. I'm a noob.

    I forgot !preg_match. Thanks for replying though.

Reply

You must log in to post.

About this Topic