@ 2014-05-25T23:05:39Z <?php
$regex = '/(?<!<br>)(?<!\s)\s*(\((?:(?:(?!<br>|\(|\)).)*(?:\((?:(?!<br>|\(|\)).)*\))?)*?\))\s*(\{)/si';
$test_string = '<br> var allowed = true, human_exists = true, stop_computers = false, current_player_number = 1, row_amount = 6, column_amount = 7;<br> function check_board () {<br> computer_number = current_player_number;<br> other_player_number = (computer_number === 1) ? 2 : 1;<br> var board = {};<br> $(""STRING"").each(function () {<br> if ($(this).hasClass(""STRING"" + other_player_number)) {<br> board[this.id] = 1;<br> }<br> else if ($(this).hasClass(""STRING"" + computer_number)) {<br> board[this.id] = 2;<br> }<br> else {<br> board[this.id] = 0;<br> }<br> });<br> board = {""STRING"": JSON.stringify(board), ""STRING"": column_amount, ""STRING"": row_amount};<br> $.ajax ({<br> type: ""STRING"",<br> url: ""STRING"",<br> data: board,<br> success: function (data) {<br> input = board;<br> output = data;<br> board = JSON.parse(data);<br> if (!board[""STRING""] ""SYMBOL""""SYMBOL"" board[""STRING""] === false) {<br> $(""STRING"").html($(""STRING"" + other_player_number + ""STRING"").html());<br> $(""STRING"")[0].style.backgroundColor = (other_player_number === 1) ? ""STRING"": ""STRING"";<br> current_player_number = other_player_number;<br> allowed = true;<br> }<br> else if (board[""STRING""]) {<br> $(""STRING"").html(""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> current_player_number = null;<br> }<br> else {<br> if (board[""STRING""] === 1 || board[""STRING""] === ""STRING"") {<br> $(""STRING"").html($(""STRING"" + other_player_number + ""STRING"").html() + ""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> $(""STRING"" + other_player_number + ""STRING"").html(parseInt($(""STRING"" + other_player_number + ""STRING"").html(), 10) + 1);<br> }<br> else {<br> $(""STRING"").html($(""STRING"" + computer_number + ""STRING"").html() + ""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> $(""STRING"" + computer_number + ""STRING"").html(parseInt($(""STRING"" + computer_number + ""STRING"").html(), 10) + 1);<br> }<br> current_player_number = null;<br> }<br> },<br> fail: function (one, two, three) {<br> console.log(one);<br> console.log(two);<br> console.log(three);<br> }<br> });<br> }<br> function computer_turn_process () {<br> allowed = false;<br> computer_number = current_player_number;<br> other_player_number = (computer_number === 1) ? 2 : 1;<br> var board = {};<br> $(""STRING"").each(function () {<br> if ($(this).hasClass(""STRING"" + other_player_number)) {<br> board[this.id] = 1;<br> }<br> else if ($(this).hasClass(""STRING"" + computer_number)) {<br> board[this.id] = 2;<br> }<br> else {<br> board[this.id] = 0;<br> }<br> });<br> board = {""STRING"": JSON.stringify(board), ""STRING"": true, ""STRING"": column_amount, ""STRING"": row_amount};<br> $.ajax ({<br> type: ""STRING"",<br> url: ""STRING"",<br> data: board,<br> success: function (data) {<br> input = board;<br> output = data;<br> board = JSON.parse(data);<br> for (var index_new = 0;<br> index_new ""SYMBOL"" (row_amount * column_amount);<br> index_new++) {<br> if (board[index_new] === 1) {<br> if (computer_number !== other_player_number) {<br> $(""STRING"" + index_new).removeClass(""STRING"" + computer_number).addClass(""STRING"" + other_player_number);<br> }<br> }<br> else if (board[index_new] === 2) {<br> if (computer_number !== other_player_number) {<br> $(""STRING"" + index_new).removeClass(""STRING"" + other_player_number).addClass(""STRING"" + computer_number);<br> }<br> }<br> }<br> if (!board[""STRING""] ""SYMBOL""""SYMBOL"" board[""STRING""] ""SYMBOL""""SYMBOL"" board[""STRING""] === false) {<br> $(""STRING"").html($(""STRING"" + other_player_number + ""STRING"").html());<br> $(""STRING"")[0].style.backgroundColor = (other_player_number === 1) ? ""STRING"": ""STRING"";<br> current_player_number = other_player_number;<br> if (human_exists) {<br> allowed = true;<br> }<br> else if (!stop_computers) {<br> computer_turn_process ();<br> }<br> }<br> else if (board[""STRING""]) {<br> $(""STRING"").html(""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> current_player_number = null;<br> }<br> else {<br> if (board[""STRING""] === 1 || board[""STRING""] === ""STRING"") {<br> $(""STRING"").html($(""STRING"" + other_player_number + ""STRING"").html() + ""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> $(""STRING"" + other_player_number + ""STRING"").html(parseInt($(""STRING"" + other_player_number + ""STRING"").html(), 10) + 1);<br> }<br> else {<br> $(""STRING"").html($(""STRING"" + computer_number + ""STRING"").html() + ""STRING"");<br> $(""STRING"").html(""STRING"");<br> $(""STRING"")[0].style.display = ""STRING"";<br> $(""STRING"" + computer_number + ""STRING"").html(parseInt($(""STRING"" + computer_number + ""STRING"").html(), 10) + 1);<br> }<br> current_player_number = null;<br> }<br> },<br> fail: function (one, two, three) {<br> console.log(one);<br> console.log(two);<br> console.log(three);<br> }<br> });<br> }<br> $(""STRING"").each(function () {<br> this.innerHTML = ""STRING"";<br> });<br> function human_and_computer_turns (noclick) {<br> human_exists = true;<br> if ($(""STRING"").val() === ""STRING"") {<br> computer_number = 2;<br> }<br> else {<br> computer_number = 1;<br> }<br> other_player_number = (computer_number === 1) ? 2 : 1;<br> if (noclick !== ""STRING"") {<br> column = Math.floor(this.id % column_amount);<br> if (allowed) {<br> allowed = false;<br> for (var index = column + (column_amount * (row_amount - 1));<br> index ""SYMBOL""= column;<br> index -= column_amount) {<br> if (!$(""STRING"" + index).hasClass(""STRING"" + computer_number) ""SYMBOL""""SYMBOL"" !$(""STRING"" + index).hasClass(""STRING"" + other_player_number)) {<br> $(""STRING"" + index).addClass(""STRING"" + other_player_number);<br> $(""STRING"").html($(""STRING"" + computer_number + ""STRING"").html());<br> current_player_number = computer_number;<br> $(""STRING"")[0].style.backgroundColor = (other_player_number === 1) ? ""STRING"" : ""STRING"";<br> computer_turn_process(computer_number);<br> break;<br> }<br> else if (index === column) {<br> ""COMMENT""allowed = true;<br> }<br> }<br> }<br> }<br> else {<br> allowed = false;<br> computer_turn_process(computer_number);<br> }<br> }<br> function human_only_turns () {<br> human_exists = true;<br> other_player_number = (current_player_number === 1) ? 2 : 1;<br> column = Math.floor(this.id % column_amount);<br> if (allowed) {<br> allowed = false;<br> for (var index = column + (column_amount * (row_amount - 1));<br> index ""SYMBOL""= column;<br> index -= column_amount) {<br> if (!$(""STRING"" + index).hasClass(""STRING"" + current_player_number) ""SYMBOL""""SYMBOL"" !$(""STRING"" + index).hasClass(""STRING"" + other_player_number)) {<br> $(""STRING"" + index).addClass(""STRING"" + current_player_number);<br> check_board();<br> break;<br> }<br> else if (index === column) {<br> ""COMMENT""allowed = true;<br> }<br> }<br> }<br> }<br> function start_game () {<br> if (current_player_number === null) {<br> return false;<br> }<br> $(""STRING"").unbind(""STRING"", human_and_computer_turns);<br> $(""STRING"").unbind(""STRING"", human_only_turns);<br> ""COMMENT""stop_computers = true;<br> if ($(""STRING"").val() === ""STRING"" ""SYMBOL""""SYMBOL"" $(""STRING"").val() === ""STRING"") {<br> allowed = false;<br> human_exists = false;<br> stop_computers = false;<br> computer_turn_process(1);<br> }<br> else if ($(""STRING"").val() === ""STRING"" ""SYMBOL""""SYMBOL"" $(""STRING"").val() === ""STRING"") {<br> allowed = true;<br> $(""STRING"").on(""STRING"", human_only_turns);<br> }<br> else {<br> if ($(""STRING"").val() === ""STRING"") {<br> computer_number = 2;<br> }<br> else {<br> computer_number = 1;<br> }<br> if (current_player_number === computer_number) {<br> allowed = false;<br> human_and_computer_turns(""STRING"");<br> }<br> else {<br> allowed = true;<br> }<br> $(""STRING"").on(""STRING"", human_and_computer_turns);<br> }<br> }<br> $(""STRING"").click(function () {<br> current_player_number = 1;<br> $(""STRING"").each(function () {<br> this.className = ""STRING"";<br> });<br> $(""STRING"").html(""STRING"");<br> $(""STRING"").html($(""STRING"").html());<br> $(""STRING"")[0].style.display = ""STRING"";<br> $(""STRING"")[0].style.backgroundColor = ""STRING"";<br> start_game();<br> });<br> $(""STRING"").on(""STRING"", function (event) {<br> return clean (event, ""STRING"");<br> }).on(""STRING"", function () {<br> this.value = clean_paste (this.value, ""STRING"");<br> $(""STRING"" + this.id).html(this.value.toUpperCase());<br> });<br> $(""STRING"").on(""STRING"", function () {<br> start_game();<br> });<br> $(function () {<br> start_game();<br> });';
echo preg_replace($regex,' $1 $2',$test_string);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.009 0.009 16.50 8.3.5 0.012 0.011 22.03 8.3.4 0.012 0.006 18.84 8.3.3 0.011 0.007 19.08 8.3.2 0.006 0.003 20.13 8.3.1 0.003 0.007 23.53 8.3.0 0.010 0.000 19.51 8.2.18 0.004 0.014 18.17 8.2.17 0.012 0.009 22.96 8.2.16 0.012 0.006 20.25 8.2.15 0.006 0.003 24.18 8.2.14 0.000 0.010 24.66 8.2.13 0.003 0.007 26.16 8.2.12 0.004 0.008 22.32 8.2.11 0.004 0.011 22.33 8.2.10 0.000 0.014 18.05 8.2.9 0.007 0.003 19.23 8.2.8 0.000 0.010 17.97 8.2.7 0.009 0.005 17.38 8.2.6 0.003 0.007 18.04 8.2.5 0.004 0.007 18.07 8.2.4 0.000 0.011 18.16 8.2.3 0.003 0.007 18.05 8.2.2 0.003 0.007 17.97 8.2.1 0.000 0.011 18.02 8.2.0 0.003 0.013 17.80 8.1.28 0.010 0.010 25.92 8.1.27 0.003 0.007 22.32 8.1.26 0.003 0.006 26.35 8.1.25 0.005 0.005 28.09 8.1.24 0.010 0.000 22.48 8.1.23 0.009 0.006 17.76 8.1.22 0.000 0.010 17.76 8.1.21 0.004 0.007 18.77 8.1.20 0.000 0.012 17.35 8.1.19 0.004 0.007 17.41 8.1.18 0.006 0.006 18.10 8.1.17 0.000 0.011 18.74 8.1.16 0.000 0.011 22.13 8.1.15 0.003 0.007 18.67 8.1.14 0.003 0.007 17.58 8.1.13 0.003 0.006 17.89 8.1.12 0.010 0.000 17.62 8.1.11 0.004 0.007 17.53 8.1.10 0.000 0.010 17.46 8.1.9 0.000 0.010 17.57 8.1.8 0.007 0.003 17.57 8.1.7 0.000 0.010 17.55 8.1.6 0.003 0.008 17.69 8.1.5 0.003 0.009 17.57 8.1.4 0.004 0.008 17.54 8.1.3 0.003 0.008 17.69 8.1.2 0.005 0.005 17.73 8.1.1 0.000 0.012 17.65 8.1.0 0.003 0.007 17.61 8.0.30 0.007 0.003 18.77 8.0.29 0.000 0.010 17.17 8.0.28 0.000 0.010 18.50 8.0.27 0.000 0.010 17.23 8.0.26 0.005 0.005 17.33 8.0.25 0.006 0.003 17.04 8.0.24 0.003 0.009 16.97 8.0.23 0.003 0.007 17.10 8.0.22 0.003 0.006 16.98 8.0.21 0.000 0.010 17.03 8.0.20 0.003 0.006 17.08 8.0.19 0.000 0.010 17.07 8.0.18 0.004 0.007 17.02 8.0.17 0.003 0.009 16.95 8.0.16 0.003 0.007 17.02 8.0.15 0.003 0.007 16.92 8.0.14 0.000 0.010 16.98 8.0.13 0.005 0.005 13.44 8.0.12 0.005 0.005 16.95 8.0.11 0.006 0.006 17.06 8.0.10 0.000 0.010 16.98 8.0.9 0.003 0.007 17.02 8.0.8 0.010 0.010 16.95 8.0.7 0.000 0.010 17.02 8.0.6 0.000 0.010 17.06 8.0.5 0.007 0.004 16.84 8.0.3 0.011 0.016 17.39 8.0.2 0.008 0.017 17.43 8.0.1 0.003 0.007 17.03 8.0.0 0.008 0.017 17.02 7.4.33 0.000 0.008 15.00 7.4.32 0.003 0.007 16.72 7.4.30 0.003 0.007 16.78 7.4.29 0.007 0.003 16.67 7.4.28 0.006 0.006 16.59 7.4.27 0.003 0.007 16.79 7.4.26 0.003 0.006 16.82 7.4.25 0.003 0.007 16.66 7.4.24 0.002 0.007 16.73 7.4.23 0.010 0.000 16.75 7.4.22 0.009 0.015 16.64 7.4.21 0.007 0.013 16.79 7.4.20 0.005 0.005 16.80 7.4.19 0.000 0.010 16.83 7.4.16 0.010 0.013 16.79 7.4.15 0.006 0.017 17.40 7.4.14 0.015 0.013 17.86 7.4.13 0.005 0.017 16.61 7.4.12 0.009 0.016 16.60 7.4.11 0.004 0.021 16.74 7.4.10 0.013 0.010 16.76 7.4.9 0.008 0.016 16.70 7.4.8 0.010 0.016 19.39 7.4.7 0.014 0.008 16.60 7.4.6 0.018 0.006 16.57 7.4.5 0.003 0.009 16.57 7.4.4 0.013 0.006 22.77 7.4.3 0.009 0.012 16.66 7.4.0 0.003 0.017 15.03 7.3.33 0.000 0.008 13.00 7.3.32 0.003 0.006 13.20 7.3.31 0.003 0.007 16.19 7.3.30 0.003 0.006 16.31 7.3.29 0.017 0.011 16.32 7.3.28 0.011 0.011 16.34 7.3.27 0.010 0.014 17.40 7.3.26 0.012 0.010 16.55 7.3.25 0.010 0.013 16.66 7.3.24 0.009 0.022 16.64 7.3.23 0.013 0.010 16.48 7.3.21 0.013 0.013 16.43 7.3.20 0.007 0.019 19.39 7.3.19 0.007 0.023 16.64 7.3.18 0.011 0.011 16.51 7.3.17 0.009 0.012 16.39 7.3.16 0.000 0.023 16.39 7.3.12 0.013 0.007 14.69 7.2.33 0.003 0.020 16.73 7.2.32 0.006 0.016 16.51 7.2.31 0.010 0.013 16.66 7.2.30 0.013 0.010 16.68 7.2.29 0.010 0.013 16.61 7.2.6 0.093 0.014 15.27 7.2.0 0.000 0.019 19.54 7.1.20 0.006 0.009 16.05 7.1.10 0.068 0.000 9.73 7.1.7 0.006 0.006 17.11 7.1.6 0.013 0.019 19.33 7.1.5 0.007 0.026 17.10 7.1.0 0.007 0.080 22.39 7.0.20 0.039 0.011 14.64 7.0.14 0.003 0.073 22.15 7.0.6 0.030 0.083 19.82 7.0.5 0.003 0.060 17.93 7.0.4 0.000 0.050 20.02 7.0.3 0.017 0.067 20.36 7.0.2 0.013 0.053 20.20 7.0.1 0.003 0.067 20.06 7.0.0 0.003 0.060 20.22 5.6.28 0.007 0.093 21.11 5.6.21 0.017 0.097 20.72 5.6.20 0.010 0.057 18.21 5.6.19 0.013 0.100 20.63 5.6.18 0.013 0.053 20.47 5.6.17 0.027 0.093 20.45 5.6.16 0.007 0.087 20.55 5.6.15 0.017 0.090 18.19 5.6.14 0.017 0.060 18.13 5.6.13 0.017 0.090 18.22 5.6.12 0.010 0.110 21.13 5.6.11 0.017 0.100 21.10 5.6.10 0.010 0.097 21.01 5.6.9 0.007 0.080 20.89 5.6.8 0.013 0.090 20.55 5.5.35 0.030 0.090 20.40 5.5.34 0.003 0.070 17.89 5.5.33 0.020 0.093 20.59 5.5.32 0.027 0.053 20.33 5.5.31 0.027 0.077 20.20 5.5.30 0.010 0.083 17.98 5.5.29 0.000 0.107 18.00 5.5.28 0.010 0.100 20.83 5.5.27 0.003 0.103 20.74 5.5.26 0.010 0.100 20.98 5.5.25 0.010 0.097 20.51 5.5.24 0.020 0.097 20.27 5.4.45 0.017 0.083 19.59 5.4.44 0.033 0.083 19.58 5.4.43 0.020 0.083 19.25 5.4.42 0.023 0.060 19.43 5.4.41 0.023 0.060 19.10 5.4.40 0.020 0.047 19.09 5.4.39 0.017 0.080 19.11 5.4.38 0.033 0.050 19.12 5.4.37 0.030 0.047 19.10 5.4.36 0.027 0.080 18.94 5.4.35 0.020 0.057 19.23 5.4.34 0.017 0.050 19.10 5.4.32 0.040 0.070 19.10 5.4.31 0.030 0.070 19.12 5.4.30 0.037 0.063 18.87 5.4.29 0.023 0.057 18.90 5.4.28 0.011 0.076 12.37 5.4.27 0.013 0.086 12.37 5.4.26 0.005 0.079 12.37 5.4.25 0.012 0.091 12.37 5.4.24 0.010 0.095 12.37 5.4.23 0.009 0.086 12.37 5.4.22 0.012 0.075 12.36 5.4.21 0.009 0.064 12.37 5.4.20 0.008 0.076 12.37 5.4.19 0.029 0.080 12.36 5.4.18 0.009 0.053 12.36 5.4.17 0.009 0.055 12.37 5.4.16 0.010 0.055 12.37 5.4.15 0.008 0.058 12.37 5.4.14 0.008 0.054 12.05 5.4.13 0.009 0.052 12.04 5.4.12 0.010 0.049 12.01 5.4.11 0.005 0.051 12.01 5.4.10 0.008 0.049 12.00 5.4.9 0.005 0.053 12.00 5.4.8 0.007 0.051 12.00 5.4.7 0.009 0.073 12.00 5.4.6 0.015 0.105 12.00 5.4.5 0.009 0.064 12.00 5.4.4 0.007 0.047 11.98 5.4.3 0.009 0.069 11.98 5.4.2 0.012 0.067 11.98 5.4.1 0.008 0.049 11.99 5.4.0 0.013 0.059 11.46 5.3.29 0.447 0.047 14.57 5.3.28 0.042 0.085 12.71 5.3.27 0.007 0.062 12.72 5.3.26 0.008 0.075 12.72 5.3.25 0.010 0.073 12.72 5.3.24 0.017 0.101 12.71 5.3.23 0.018 0.126 12.71 5.3.22 0.008 0.085 12.68 5.3.21 0.012 0.075 12.68 5.3.20 0.010 0.057 12.68 5.3.19 0.010 0.052 12.68 5.3.18 0.010 0.051 12.67 5.3.17 0.007 0.052 12.67 5.3.16 0.009 0.049 12.68 5.3.15 0.006 0.053 12.68 5.3.14 0.007 0.051 12.66 5.3.13 0.005 0.055 12.66 5.3.12 0.011 0.050 12.66 5.3.11 0.008 0.053 12.66 5.3.10 0.007 0.052 12.14 5.3.9 0.009 0.048 12.11 5.3.8 0.005 0.051 12.09 5.3.7 0.006 0.050 12.09 5.3.6 0.012 0.044 12.08 5.3.5 0.006 0.057 12.02 5.3.4 0.012 0.051 12.02 5.3.3 0.010 0.053 11.98 5.3.2 0.013 0.052 11.76 5.3.1 0.012 0.051 11.73 5.3.0 0.008 0.054 11.71 5.2.17 0.012 0.047 9.22 5.2.16 0.045 0.116 9.22 5.2.15 0.005 0.049 9.21 5.2.14 0.007 0.057 9.21 5.2.13 0.009 0.042 9.17 5.2.12 0.009 0.052 9.18 5.2.11 0.010 0.060 9.18 5.2.10 0.011 0.043 9.18 5.2.9 0.006 0.031 9.17 5.2.8 0.007 0.033 9.17 5.2.7 0.007 0.043 9.17 5.2.6 0.006 0.041 9.13 5.2.5 0.010 0.042 9.10 5.2.4 0.011 0.040 9.08 5.2.3 0.009 0.048 9.06 5.2.2 0.007 0.042 9.04 5.2.1 0.006 0.031 8.96 5.2.0 0.004 0.040 8.82 5.1.6 0.006 0.171 8.14 5.1.5 0.005 0.188 8.14 5.1.4 0.006 0.171 8.12 5.1.3 0.007 0.209 8.46 5.1.2 0.004 0.171 8.49 5.1.1 0.007 0.173 8.22 5.1.0 0.006 0.264 8.22 5.0.5 0.008 0.240 6.69 5.0.4 0.008 0.224 6.55 5.0.3 0.008 0.159 6.36 5.0.2 0.005 0.146 6.33 5.0.1 0.006 0.184 6.31 5.0.0 0.009 0.231 6.29 4.4.9 0.003 0.156 4.78 4.4.8 0.005 0.222 4.75 4.4.7 0.006 0.207 4.76 4.4.6 0.005 0.192 4.75 4.4.5 0.004 0.175 4.77 4.4.4 0.007 0.261 4.71 4.4.3 0.007 0.271 4.76 4.4.2 0.006 0.228 4.84 4.4.1 0.009 0.276 4.85 4.4.0 0.007 0.204 4.76 4.3.11 0.003 0.155 4.67 4.3.10 0.009 0.177 4.67 4.3.9 0.004 0.208 4.63 4.3.8 0.008 0.185 4.61 4.3.7 0.004 0.126 4.63 4.3.6 0.009 0.209 4.63 4.3.5 0.004 0.247 4.63 4.3.4 0.004 0.220 4.55 4.3.3 0.004 0.139 3.36 4.3.2 0.007 2.430 8.19 4.3.1 0.003 2.430 8.19 4.3.0 0.007 2.457 8.19
preferences:dark mode live preview
44.2 ms | 401 KiB | 5 Q