': (: 12345),: (: 1),: (12345),: (:),: (), '.match (/\ (:\ d +\) / g) .map (v = > v.slice)
select the one that meets the requirements. Then delete the unwanted parentheses. Started using grouping. But it doesn't work.
':(:12345):(:abc),:(:abc:sv),:(:abc):asd),:(:1),:(12345),:(:),:(),'.match(/\(:[a-z0-9]+\)/gi).map(v=>v.slice(1,-1))
/\(:[a-z0-9]+\)/gi
[a-z0-9]
"/\ (:. +?\) / g"
gets the value in parentheses, you can use capture
"/\ ((:. +?\) / g"
,
$1
is the result
var str='lsdk(:)sjdflkf(:sdkfjl)(:lskdf)sldkf:(jsklf)';
var regex=/\((:.*?)\)/g;
var result=[];
var matchStr=null;
while((matchStr=regex.exec(str))!=null){
result.push(matchStr[1]);
}
how does the regular expression find the value of a specific condition?
let text = '(:12345)'
text.replace(/.*?\((:.+)\).*/, '$1')