<?php $re = '~^(\s*//.*)(*SKIP)(*F)|^(?:\s*Connection\s+)?(.+?)\s*=\s*new\s+DBConnection~m';$str = "Connection variable = new DBConnection\n variable = new DBConnection\n //\n //Connection variable = new DBConnection\n //variable = new DBConnection\n // Connection variable = new DBConnection\n // variable = new DBConnection";if (preg_match_all($re, $str, $matches)) { print_r($matches[0]);}
Standard input is empty
Array ( [0] => Connection variable = new DBConnection [1] => variable = new DBConnection )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!