#!/www/server/bin/php -qC 'repl1', 'regex2' => 'repl2', 'regex3' => 'repl3' ), 'regex2 regex1 regex3' ), 'repl2 repl1 repl3', 'test tr regex function' ); is( it::match( '\w+', 'word1 wörd2 word_3', array('all' => true )), array( 'word1', 'wörd2', 'word_3' ), "test match_all function" ); match( 'aBcD', ' aBcD ', 'aBcD', "caseinsensitive is default" ); match( 'ö', 'Ö', 'Ö', 'match umlaute in latin1 case insensitive' ); is( it::match(utf8_encode('aöBÜ'), utf8_encode("AÖbü"), array('utf8' => true)), utf8_encode('AÖbü'), "match utf-8 umlaute in case insensitive" ); $oldcharset = ini_get('default_charset'); ini_set('default_charset', 'utf-8'); match( utf8_encode('aöBÜ'), utf8_encode('AÖbü'), utf8_encode('AÖbü'), "match utf-8 umlaute in case insensitive using default_charset" ); is( it::match('aöBÜ', 'AÖbü', array('utf8' => false)), 'AÖbü', "non-utf-8 override with default_charset=utf-8" ); match( '\w+', utf8_encode('Müller'), utf8_encode('Müller'), '\w matches umlaut in utf-8 mode' ); ini_set('default_charset', $oldcharset); is( it::match( 'abc', "aBc", array('casesensitive' => 1 )), false, "set case sensitivity by parameter" ); is( it::match( '\w+', 'word1 wörd2 word_3', array('all' => 1 )), array( 'word1', 'wörd2', 'word_3' ), "test all=>1 without captures" ); is( it::match( '\w+\s+(\d+)', 'word1 12 wörd2 3 word_3 4', array('all' => 1 )), array( '12', '3', '4' ), "test all=>1 with one capture" ); is( it::match( '(\w+)\s+(\d+)', 'word1 12 wörd2 3 word_3 4', array('all' => 1 )), array( array( 'word1', '12' ), array( 'wörd2', '3' ), array( 'word_3', '4' ) ), "test all=>1 with captures" ); is( it::match( '(\w+)\s+(\d+)', 'word1 12 wörd2 3 word_3 4', array('all' => 1, 'pattern_order' => 1 )), array( array( 'word1', 'wörd2', 'word_3' ), array( '12', '3', '4' ) ), "test all=>1,pattern_order=>1" ); is(it::replace(array('a' => "1", 'b' => "2"), "ab"), "12"); is(it::replace(array('!' => "x"), "!"), "x"); is(it::replace(array('\w' => "x"), "oö"), "xx"); is(it::replace(array('[[:alpha:]]' => "x"), "ö"), "x"); is(it::replace(array('\w' => "x", '#' => "!"), "#ö"), "!x"); is(it::replace(array('#' => "!", '\w' => "x"), "#ö"), "!x"); is(it::replace(array('ö' => "x"), "Ö"), "x"); is(it::replace(array('a' => "1"), "aaa", array('limit' => 1)), "1aa"); # it::filter_keys tests $data = array('a' => 1, 'b' => 2, 'c' => 3); is(it::filter_keys($data, 'a'), array('a' => 1), "select one key"); is(it::filter_keys($data, array('a', 'b')), array('a' => 1, 'b' => 2), "select two keys with array"); is(it::filter_keys($data, 'a,b'), array('a' => 1, 'b' => 2), "select two keys with string"); is( array_keys(it::filter_keys($data, 'b,a')), array('a', 'b'), "keep order of data array per default"); is( array_keys(it::filter_keys($data, 'b,a', array('reorder' => true))), array('b', 'a'), "reorder with given key order"); # it::date tests is(it::date('date', '2011-10-25'), '25.10.2011', 'parse date string with strtotime'); is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'some date arithmetic'); is(it::date('datetime', time()), it::date('datetime'), 'recognize int as timestamp'); is(it::date('datetime', time()*1.0), it::date('datetime'), 'recognize float as timestamp'); is(it::date('datetime', time() . ''), it::date('datetime'), 'recognize digit string as timestamp'); is(it::date('datetime', '@' . time()), it::date('datetime'), 'recognize strtotime timestamp format'); is(it::date('datetime', 10), it::date('datetime', "10"), 'numeric and string give same result'); is(it::date('datetime', 10.0), it::date('datetime', "10"), '... as long as num is properly truncated'); is(it::date('datetime', 10.5), it::date('datetime', "10"), '... with one digit after point'); is(it::date('datetime', 10.56), it::date('datetime', "10"), '... with two digits after point'); is(it::date('datetime', 1000000), it::date('datetime', "1000000"), '... large nummer'); is(it::date('datetime', 1000000.543), it::date('datetime', "1000000"), '... large nummer and point'); is(it::date('time', "10.5"), "10:05", 'interpret string with points with strtotime'); is(it::date('time', "10.05"), "10:05", 'interpret string with points with strtotime'); ?>