Validation with regular expression in javascript and php

How to validate phone, email etc., using regular expression in javascript and php. Here is simple example use of REGEXP and list for huge source of regular expression. You can found unique REGEXP that will validate different type of email, phone, URI, address, string, Markup and code etc.,

/^[2-9]\d{2}-\d{3}-\d{4}$/
This expression matches a hyphen separated US phone number, of the form ANN-NNN-NNNN, where A is between 2 and 9 and N is between 0 and 9. for example 333-444-1234
REGEXP use in PHP:

<?php
function checkPhone(val){
    if(preg_match('/^[2-9]\d{2}-\d{3}-\d{4}$/', '333-444-1234'))
        return TRUE;
    else
        return FALSE;
}
?>

REGEXP use in javascript:

<script>
function checkPhone(val){
    var pattern = /^[2-9]\d{2}-\d{3}-\d{4}$/;
    if(pattern.test(val))
        return true;
    else
        return false;
}
</script>

Working example in javascript:

Field only allow phone pattern like: 333-444-1234

Regular expression library:
You can found all kind of regular expression here regexlib.com