JS-正则表达式
发布日期:2021-05-09 22:46:03 浏览次数:17 分类:精选文章

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

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

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

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

  • // /^(0|+?[1-9][0-9]*)$/; // 0������������
  • // /^[1-9]\d$/; // ���������*

������������������������������������������������������������0 ���������������


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

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

str.replace(/^\s+|\s+$/g, '');
  • ^\s+���������������������������������������
  • \s+$���������������������������������������
  • g���������������������������������������������������
  • ''������������������������

���������

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


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

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

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

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

    /^[1-9]\d*$/

    ���������������������1-9���������������������0-9���������������������������

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

    ������������������������������������0���������������������������������

    /^(0|\+?[1-9][0-9]*)$/

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

    • ���������0
    • ������������������������������������������+1���
    • ������������������������������������

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

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

    ���������������������������������������������������������������������������������������������������������^���$������������������������������

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

    ���������������������������������������������������������������������������������������������������Unicode���������

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

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


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

    ���������������������������replace������������������������������������

    // ������������������������������
    const str = " ������������ ";
    const result = str.replace(/^\s+|\s+$/g, '');
    console.log(result); // ������: ������������

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


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

    ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������replace������������������������������������������������������������������������������������������������

    上一篇:ES6-Number
    下一篇:Taro学习手册(五)—— 遇到的bug

    发表评论

    最新留言

    能坚持,总会有不一样的收获!
    [***.219.124.196]2025年04月05日 04时43分25秒