提取所有以某個字符開頭某個字符結尾的字符串

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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章