Skip to content

Instantly share code, notes, and snippets.

@nicholasxjy
Last active February 27, 2020 03:09
Show Gist options
  • Save nicholasxjy/40340451dbfe4447e96622b18818395d to your computer and use it in GitHub Desktop.
Save nicholasxjy/40340451dbfe4447e96622b18818395d to your computer and use it in GitHub Desktop.
some useful regex
// mobile phone numbers in china
const reg = /^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/
// image tag
const regex = /<img([\s\S]*?)src\s*=\s*(['"])([\s\S]*?)\2([^>]*)>/gi
// only chinese charactors and letters
const regex = /^[\u4e00-\u9fa5a-zA-Z]+$/
// email
const reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment