Replace string that starts with specific character and ends with specific character in regular expression
javascript, regex
Solution
This pattern should work for replace anything between brackets (including the brackets):
var reg = /(\[.*?\])/gi;
var str = "asdfkadsf[xxxxx]bb";
var test = str.replace(reg,"") == "asdfkadsfbb"
Problem
I wanted to replace a string section that starts with a specific character and ends with specific character. At below, I demonstrate test case. ``` var reg = /pattern/gi; var str = "asdfkadsf[xxxxx]bb"; var test = str.replace(reg,"") == "asdfkadsfbb" console.log(test); ```