V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Sin
V2EX  ›  Node.js

Node.js 正则表达式匹配失败

  •  
  •   Sin · 2013-02-09 10:33:12 +08:00 · 5766 次点击
    这是一个创建于 4087 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在循环里进行正则表达式匹配的时候,经常出现没有理由的匹配失败,例如

    try
     match = re.match(str)[1] # TypeError: Cannot read property '1' of null
    catch error
     match = re.match(str)[1] # 完全正常

    求解
    2 条回复    1970-01-01 08:00:00 +08:00
    bitsmix
        1
    bitsmix  
       2013-02-09 11:20:56 +08:00 via iPhone
    你自己的问题。
    wsph123
        2
    wsph123  
       2013-02-11 17:13:11 +08:00   ❤️ 1
    match返回不一定有[1]
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2855 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:21 · PVG 19:21 · LAX 04:21 · JFK 07:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.