js string matching brackets

function getParenthesesStr(text) {//截取括号中的字符串
	    var result = ''
	    if ($.trim(text)!=""){
	    var regex = /\((.+?)\)/g;
	    var options = text.match(regex);
	    if ($.trim(options)!="") {
	        var option = options[0]
	        if ($.trim(option)!="") {
	            result = option.substring(1, option.length - 1)
	        }
	    }
	   }
	    return result;
	}
Published 19 original articles · won praise 11 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43392673/article/details/91038614