Skip to content

Instantly share code, notes, and snippets.

@1mehdifaraji
Last active November 11, 2023 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1mehdifaraji/3f90f9109e3b5478ba273bb07ca45bfc to your computer and use it in GitHub Desktop.
Save 1mehdifaraji/3f90f9109e3b5478ba273bb07ca45bfc to your computer and use it in GitHub Desktop.
Regexes mostly for iran country
export const regexes = {
iran_melli_code: /^(?!(\d)\1{9})\d{10}$/,
number_only: /^[0-9\b]+$/,
latin_number_only: /^[0-9]+$/,
iran_phone: /^(0)9(0[1-5]|[1 3]\d|2[0-2]|9[0-4]|98)\d{7}$/,
iran_shaba: /^(?:IR)(?=.{24}$)[0-9]*$/,
};
// How to use
// const isValidPhone = regexes.iran_phone.test("09371101600")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment