JSFiddle - React, Tailwind, and code Playground

by AaronLayton

HTML

<textarea id="txtLinks" placeholder="Enter the list of links here"></textarea>
<div id="output"></div>
<input type="text" id="txtReg" value="\([0-9]*\)" />
<button id="btnTest" value="Test">Test</button>

CSS

body {
    font-family:arial;
    font-size:11px;
}

#txtLinks {
    border:1px solid #ccc;
    font-family:arial;
    font-size:11px;
    height:150px;
    width:100%;
}

#output {
    border:1px solid #ccc;
    height:150px;
    width:100%;
}

JavaScript

// Yours Regex
// (?<=\()[0-9]*(?=\))
//
// (?!\()[0-9]*(?=\))

//   \([0-9]*\)


$('#btnTest').click(function(){
    $('#output').html("");
    
    var re = new RegExp($('#txtReg').val());
    /*
    var patt=new RegExp(pattern,modifiers);

    or more simply:
    
    var patt=/pattern/modifiers;
    */
    var result = re.exec($('#txtLinks').val());
    
    $('#output').append(re);
    
    $('#output').append(result);
    
    $('#output').append(result[0]);
    $('#output').append(getIndicesOf("\([0-9]*\)", $('#txtLinks').val(), false));
});

function getIndicesOf(searchStr, str, caseSensitive) {
    var startIndex = 0, searchStrLen = searchStr.length;
    var index, indices = [];
    if (!caseSensitive) {
        str = str.toLowerCase();
        searchStr = searchStr.toLowerCase();
    }
    while ((index = str.indexOf(searchStr, startIndex)) > -1) {
        indices.push(index);
        startIndex = index + searchStrLen;
    }
    return indices;
}