Sin
V2EX  ›  Node.js

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

  •  
  •   Sin · Feb 9, 2013 · 6463 views
    This topic created in 4848 days ago, the information mentioned may be changed or developed.
    在循环里进行正则表达式匹配的时候,经常出现没有理由的匹配失败,例如

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

    求解
    2 replies    1970-01-01 08:00:00 +08:00
    bitsmix
        1
    bitsmix  
       Feb 9, 2013 via iPhone
    你自己的问题。
    wsph123
        2
    wsph123  
       Feb 11, 2013   ❤️ 1
    match返回不一定有[1]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5764 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 02:08 · PVG 10:08 · LAX 19:08 · JFK 22:08
    ♥ Do have faith in what you're doing.