正则匹配括号中内容

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		var reg = /\((.+?)\)/g;
		var reg2 = /\((.+?)\)/;
		var str = 'scale(1.5) rotate(20deg) translate(20px)';
		var result = str.match(reg);
		result.forEach(function(i){
			var result2 = i.match(reg2);
			// console.log(result2[0]);
			console.log(result2[1]);
		})
	</script>
</body>
</html>
posted @ 2017-06-06 16:25  wmui  阅读(4402)  评论(0)    收藏  举报