RegExp:正则表达式对象 || Global对象
发布日期:2021-05-10 19:04:30 浏览次数:11 分类:精选文章

本文共 2447 字,大约阅读时间需要 8 分钟。

������������������Global������

���������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

  • ������������

    • [ ] ������������������������������������������[a] ������������ a���[ab] ������������ a ��� b���[a-zA-Z0-9_] ������������������������������������
    • \d ������������������������ [0-9]���
    • \w ������������������������������������������������������������ [a-zA-Z0-9_]���
  • ������������

    • ? ������������0������1������������ a? ������������ a ������������ a���
    • * ������������0��������������������� a* ������������ a ��������� a���
    • + ������������������1������������ a+ ������������������������ a���
    • {m,n} ������������ m ������ n ���������������������{,n} ������������ n ������{m,} ������������ m ������
  • ������������������

    • ^ ���������������������������������
    • $ ���������������������������������

  • Global������

    Global������������������������������������������������ JavaScript ���������������������������������������������������������������������������

  • ������������

    • encodeURI() ��� decodeURI() ��������� URL ������������������������
    • encodeURIComponent() ��� decodeURIComponent() ��� encodeURI() ������������������������������������������������
    • parseInt() ������������������������������������������������ whether each character is a digit���������������������������������������
    • isNaN() ������������������������ NaN���Not a Number��������������������������������� NaN ���������������������������
  • eval()

    • ������������ JavaScript ���������������������������������������������������������

  • ������������

    // ���������������������������const reg = /^\w{6,12}$/;const username = "zhangsan";const flag = reg.test(username);console.log(flag); // ������ true
    // ������URL ���������������const url = "http://www.baidu.com?wd=���������";const encoded = encodeURI(url);console.log(encoded); // `%E4%BC%A0%E6%99%BA%E6%92%AD%E5%AE%A2`const decoded = decodeURI(encoded);console.log(decoded); // "���������"

    ������������

    • ������������������������������������������������������������������������������������
    • Global��������������������������� parseInt ������������������������������������������
    • NaN ������������������������ false���������������������������������������������������������������������������

    ������������������������������������ Global���������������������������������������������������������

    上一篇:三层架构 || SpringMVC 和 Struts2 的优略分析
    下一篇:取 1~100之间的随机整数

    发表评论

    最新留言

    路过,博主的博客真漂亮。。
    [***.116.15.85]2025年04月18日 10时07分20秒