Basic regular expression in JavaScript

后端 未结 6 1990
[愿得一人]
[愿得一人] 2021-01-23 04:55

For some time I\'ve been trying to understand regular expressions in JavaScript, but it is extremely complicated. You could tell me how do I redeem separately each of the values

6条回答
  •  一整个雨季
    2021-01-23 05:47

    Here you go, try this out:

    var string = "/first/middle/last";
    var pattern = /([^\/]+)/g;
    var result = string.match(pattern);
    
    for (var i = 0; i < result.length; ++i) {
        var value = result[i];
        alert(value);
    } 
    

    Also you can check out this demo

提交回复
热议问题