PHP regular expression test

What is the output?

/*
$string = ‘This is a [templateVar]’;

preg_match_all(“/[[]]/”, $string, $matches);

foreach($matches[0] as $value)

{

echo $value;

}

*/

/*
$string = “Is this all there is?”;

echo(preg_match(“/[^A-J]/”,$string,$matches));
*/

/*
$string = “10 or 100 or 1000?”;

preg_match_all(“/d{2}/”, $string,$matches);

foreach($matches[0] as $value)

{

echo $value;

}
*/

/*
$string = ‘six at noon taxes’;

echo preg_match(“/s.x/”, $string, $matches);

*/
/*

$string = “Welcome to the new era”;

preg_match_all(“/[h-b]/”,$string,$matches);

foreach($matches[0] as $value)

{

echo $value;

}
*/

/*

$keywords = preg_split(“/[s,]+/”, “php, regular expressions”);

print_r( $keywords );
*/

/*

$string = ‘%Give_result%’;

preg_match_all(“/[W]/”, $string, $matches);

foreach($matches[0] as $value)

{

echo $value;

}
*/

/*
$keywords = ‘$40 for a g3/400’;

$keywords = preg_quote($keywords, ‘/’);

echo $keywords;
*/

/*
preg_match(‘/(?:D+|<d+>)*[!?]/’, ‘foobar foobar foobar’);

if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {

echo ‘Backtrack limit was exhausted!’;

}
*/

/*
$string = ‘The Lord is the God’;

if(preg_match(“/the+(?!is)/i”, $string,$match))

{

print_r($match);

}

*/

/*
$string = ‘The GOD is the Lord.’;

$string = preg_replace(“/The/g”, ‘Ze’, $string);

echo $string;
*/

/*
$str = ‘string’;

$chars = preg_split(‘//’, $str, -1, PREG_SPLIT_NO_EMPTY);

print_r($chars);

*/

/*
$string = ‘ball’;

echo preg_match(“/b[aoiu]l/”, $string, $matches);
*/

/*
$string = “Is this all there is?”;

preg_match_all(“/[a-h]/”,$string,$matches);

foreach($matches[0] as $value)

{

echo $value;

}

*/

/*

$str=”This lathe turns wood.”;

echo(preg_match(“/Btheb/”, $str));
*/

/*
$string = ‘I live in the whitehouse’;

if(preg_match(“/(?<!blue)house/i”, $string))

{

echo ‘Found a match’;

}

else

{

echo ‘No match found’;

}

*/

$string = “1, 100 or 1000?”;

preg_match_all(“/10*/”,$string,$matches);

foreach($matches[0] as $value)

{

echo $value;

}

echo” //////////////////////”;

///echo preg_replace(“/([Cc]opyright) 200(3|4|5|6)/”, “$1 2007”, “Copyright 2005”);

/*
$names = array(‘Andrew’,’John’,’Peter’,’Nastin’,’Bill’);

$output = preg_grep(‘/^[a-m]/i’, $names);

print_r( $output );
*/

$string = ‘This is the {_FOO_} brought to you by {_BAR_}’;

$template_vars=array(“FOO” => “The PHP Way”, “BAR” => “PHPro.orG”);

$string = preg_replace(“/{_(.*?)_}/ime”, “$template_vars[‘$1’]”,$string);

echo $string;

 

Javascript teszt kérdés lehet

Mi a kimenete az alábbi kód(ok)nak?

function a(version) {

this.version = version;

}

a.prototype.version = ‘1.8’;

var b = new a(‘1.8.1’);

delete b.version;

var c = b.version;

alert(c);

/*
function a() {

(‘Outer function!’);

return function(){

(‘Inner function!’);

};

}

var a = a();

a();
*/

//(typeof(Infinity));

/*
var a = ‘1’;

b = 2 * a;

c = typeof(b);

(c);

*/

/*
function a() {

var x = [];

var i = 0;

a[i] = function(){

return i;

}

i++;

(a[0]());

}

a();

*/

//(null == null);

//(self == window);

/*

if (document.addEventListener){

(“addEventListener”);

} else if (document.attachEvent){

(“attachEvent”);

*/

/*
function a(){}

var b = typeof(a.prototype);

(b);
*/

/*
var a = {a1: 1, a2: 2};

var b = 0;

for (i in a) {

b += a[i];
}

(b);

*/

/*

var a = {f: 1};

var b = a;

b.f = 100;

var c = a.f;

(c);
*/
//(typeof(somevar));

/*

function test()

{

return “Hello”;

}

alert(test());

*/

 

15 Great JavaScript Interview Questions