常用Regex Pattern

  1. 密碼原則檢核
  2. Email檢核
  3. 台灣手機號碼��
  4. 台灣身分證字號��

密碼原則檢核

  • 8個字元

  • 要有大小寫字母

  • 1個數字

    /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/

    password-regex-pattern1

  • 8個字元

  • 要有大小寫字母

  • 1個數字

  • 包含特殊符號

    /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/

    password-regex-pattern2

Email檢核

/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/

email-regex

台灣手機號碼��

/^09\d{8}$/

台灣身分證字號��

/^[A-Z]{1}[1-2]{1}[0-9]{8}$/

rubular - regex測試網站
https://rubular.com/
regexper - 將Regex用圖示表現
https://regexper.com/