V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
zxCoder

js 正则表达式怎么匹配 |

  •  
  •   zxCoder · Oct 30, 2021 · 1943 views
    This topic created in 1651 days ago, the information mentioned may be changed or developed.

    我想用|和-分割字符串

    split(/||-/)

    第一个|要怎么写,\|吗?好像不行

    user4201
        1
    user4201  
       Oct 30, 2021
    split(/[-|]/)
    2i2Re2PLMaDnghL
        2
    2i2Re2PLMaDnghL  
       Oct 30, 2021
    "123|456-789".split(/\||-/)
    Array(3) [ "123", "456", "789" ]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 08:05 · PVG 16:05 · LAX 01:05 · JFK 04:05
    ♥ Do have faith in what you're doing.