JavaScript Regex split by hyphen and spaces

前端 未结 2 1818
别跟我提以往
别跟我提以往 2021-01-26 05:17

I have a string in the following format: 90000 - 90000 Where the numbers can be of a variable length, and then there is a space, hyphen, space between them. I\'m tr

2条回答
  •  清酒与你
    2021-01-26 06:01

    You can use split function:

    var s = '90000 - 90000';
    var a = s.split(/[ -]+/);
    console.log(a);
    

    Output:

    ["90000", "90000"]
    

提交回复
热议问题