/**
 * @since Last modified: 2024/05/21 23:55:56
 * @constant regExps
 * @description Commonly used regular expressions.
 * @property {RegExp} email - This format of "xxx@xxx.xxx" is OK.
 * @property {RegExp} ip - This format of "000.000.000.000" is OK.
 * @property {RegExp} url - This format of "http[s]://[www.]xxx.com[:8080]" is OK.
 * @property {RegExp} local - This format of "中国" is OK.
 * @property {RegExp} letter - This format of "ABCabc" is OK.
 * @property {RegExp} string - This format of "ABCabc123" is OK.
 * @property {RegExp} password - This format of "ABCabc123~!@" is OK.The charactors is from ax.regChars.
 * @property {RegExp} ymdhms - This format of "YYYY(-/)MM(-/)DD hh:mm:ss" is OK.
 * @property {RegExp} ymd - This format of "YYYY(-/)MM(-/)DD" is OK.
 * @property {RegExp} hms - This format of "hh:mm:ss" is OK.
 * @property {RegExp} ym - This format of "YYYY(-/)MM" is OK.
 * @property {RegExp} y - This format of "YYYY" is OK.
 * @property {RegExp} m - This format of "MM"(1~12/01~12) is OK.
 * @property {RegExp} d - This format of "DD"(1~31/01~31) is OK.
 * @property {RegExp} integer - This format of "123" is OK,"0123" is wrong.
 * @property {RegExp} number - This format of "[-]123[.45]" is OK.
 * @property {RegExp} cellphone - This format of "15984632569"(11 places) is OK.
 * @property {RegExp} landline - This format of "[0755|010]1569326[8]" is OK.
 * @property {object} plate - This format of "[0755|010]1569326[8]" is OK.
 * @property {RegExp} plate.oil - This format of chinese oil vehicle plate is OK.
 * @property {RegExp} plate.nev - This format of chinese new energy vehicle plate is OK.
 * @property {RegExp} id - This format of chinese 18 places id is OK.
 * @property {RegExp} zip - This format of chinese 6 places zip is OK.
 * @see {@link https://codepen.io/axui/pen/YzgPxOv|demo @ codepen}
 * @example
 * ax.regExps.email;
 * <!--return a RegExp of email -->
 */

'use strict';

import { T_obj } from "../../../types/ax";
import ax from "../global/namespace";

const regExps:T_obj = {
    email: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/,  
    ip: /^\d+\.\d+\.\d+\.\d+$/, 
    
    url: /^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/,
    locale: /^[\u0391-\uFFE5]+$/,
    letter: /^[a-zA-Z]+$/,
    string: /^[a-zA-Z0-9]+$/,
    password: `^[a-zA-Z0-9${ax.regChars}]+$`, 
    ymdhms: /^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/,
    ymd: /^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2})$/, 
    hms: /^((20|21|22|23|[0-1]\d)\:[0-5][0-9])(\:[0-5][0-9])?$/, 
    ym: /^(\d{4})(-|\/)(\d{1,2})$/,
    y: /^(\d{4})$/,
    m: /^(0?[1-9]|1[0-2])$/,
    d: /^((0?[1-9])|((1|2)[0-9])|30|31)$/, 
    integer: /^[1-9]\d*$/,
    number: /^(-?\d+)\.?(\d*)$/, 
    cellphone: /^[1][3456789][0-9]{9}$/, 
    landline: /^([0-9]{3,4}-)?[0-9]{7,8}$/,
    plate: { 
        
        nev: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/,
        oil: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/,
    },
    
    id: /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/,
    zip: /^\d{6}$/,
}
export default regExps;
