Java提取
@Test
public void test1() {
String regex = "_\\[\\((.+?)\\)\\]_";
String str1 = "費用標準爲_[(月費標準)]_元/月," +
"乙方須自_[(進場日期)]_進場爲甲方提供開盤前服務,en123_[(abc123)]_test";
// ["月費標準", "進場日期"]
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str1);
System.out.println("begin");
while (matcher.find()) {
System.out.println(matcher.group(1));
}
System.out.println(str1.replaceAll(regex, "***"));
System.out.println("end");
}
Java提取
<!DOCTYPE html>
<html>
<title>test</title>
<script type="text/javascript">
function test1() {
console.log('begin');
var str = "費用標準爲_[(月費標準)]_元/月,乙方須自_[(進場日期)]_進場爲甲方提供開盤前服務,en123_[(abc123)]_test";
console.log(str);
var re1 = /_\[\((.+?)\)\]_/g;
console.log(str.match(re1));
console.log('end');
}
test1();
</script>
<body>
body
</body>
</html>