• Phone Numbers: /^[- ()0-9+$/
  • Email Addresses: /^.+?@.+?\..+?$/
  • Blank Lines: /^\s*$/
  • Password Complexity (where n is the minimum length):
    • Alphabets only: .*(?=.{n,})(?=.*[a-zA-Z]).*
    • Alphabets & Numbers only: .*(?=.{n,})(?=.*\\d)(?=.*[a-zA-Z]).*
    • Alphabets, Numbers & Symbols( @#$%^&+=!_~ ): .*(?=.{n,})(?=.*\\d)(?=.*[a-zA-Z])(?=.*[@#$%^&+=!_~]).*

  • Capitalize first letter of a word: /\b([a-z])(\w+)\b/\u$1$2$/g;
  • Format Phone Numbers(U.S.): /^\(?(\d{3})\)?[- .]?(\d{3})[- .]?<\d{4})$/
  • Email Addresses: /^[-\w.]+@(-A-z0-9]+\.)+[A-z]{2-4}$/
  • Dates(MM-DD-YYYY): /^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/[0-9]{4}$/
  • Time(12 Hr): /^(?:0?[1-9]|1[0-2]):(?:[0-5][0-9])(?::[0-5][0-9])? [PA]\.?M\.?$/
  • Postal codes(U.S.): /^\d{5}(?:-{4})?$/
Advertisements