Skip to content

Instantly share code, notes, and snippets.

@MaximStone
Created October 7, 2018 20:22
Show Gist options
  • Save MaximStone/a6c9973eb42351e9ad637f792184dda0 to your computer and use it in GitHub Desktop.
Save MaximStone/a6c9973eb42351e9ad637f792184dda0 to your computer and use it in GitHub Desktop.
Function to analyze braces syntax
function checkBraces(str) {
let temp = str.replace(/[^()\{\}<>[\]]/g, '');
let rule = /\(\)|\[\]|\{\}|<>/g;
while(rule.test(temp)) {
temp = temp.replace(rule, '');
}
return +(temp != '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment