Sunday, February 23, 2014

RegExp javascirpt php

http://www.w3schools.com/php/php_form_url_email.asp

1.javascript exmple:

1.1
var str = "Visit W3Schools";
var patt1 = /w3schools/i;
var result = str.match(patt1);

1.2 if only return true / false

var patt1=new RegExp("e");
document.write(patt1.test("The best things in life are free"));


2.php exmple:
2.2
$email = test_input($_POST["email"]);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
$emailErr = "Invalid email format";
}

3.RegExp
email: /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/i
URL:/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i




email receipt text

No comments: