3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $regex = '(?<!<br>)(?<!\s)\s*(\((?:(?:(?!<br>|\(|\)).)*(?:\((?:(?!<br>|\(|\)).)*\))?)*?\))\s*(\{)'; $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);
Output for 4.3.11 - 5.6.28, 7.0.0 - 7.1.0
Warning: preg_replace(): Unknown modifier '(' in /in/Mo2ev on line 4
Output for hhvm-3.10.0 - 3.12.0
Warning: Unknown modifier '(': [(?<!<br>)(?<!\s)\s*(\((?:(?:(?!<br>|\(|\)).)*(?:\((?:(?!<br>|\(|\)).)*\))?)*?\))\s*(\{)] in /in/Mo2ev on line 4
Output for 4.3.0 - 4.3.10
Warning: Unknown modifier '(' in /in/Mo2ev on line 4