Permalink
Browse files

Function to check parenthesis balance

  • Loading branch information...
weavejester committed Mar 9, 2012
1 parent b77585e commit 621c552e3fc1883a21edd72525c8496f6f546a6f
Showing with 11 additions and 0 deletions.
  1. +11 −0 resources/wepl/public/index.html
@@ -9,6 +9,17 @@
<script>
var editor = null
+ var isBalanced = function(text) {
+ var brackets = text.replace(/[^\{\}\[\]\(\)]/g, '')
+ var prevBrackets = null
+ while (brackets != prevBrackets) {
+ console.log(brackets)
+ prevBrackets = brackets
+ brackets = brackets.replace(/\(\)|\[\]|\{\}/, '')
+ }
+ return (brackets == "")
+ }
+
var fixHeight = function(editor) {
var prevLineCount = null
var container = $('#editor')

0 comments on commit 621c552

Please sign in to comment.