Best Phpunit code snippet using RegularExpression
syn.php
Source:syn.php
1<?php2$debug=0;3#SYN:xondre084function Help() {5 echo "Napoveda pre skript syn.php\n".6 "--help alebo -h\t= vypise tuto napovedu\n".7 "--br\t= za kazdy riadok prida <br />\n".8 "--input=xxx alebo -i=xxx\t= vstupny subor xxx\n".9 "--output=xxx alebo -o=xxx\t= vystupny subor xxx\n".10 "--format=xxx alebo -f=xxx\t= formatovaci subor\n";11}12 $ChybaArgumentov=0;13 $ChybaVstup=0;14 $ChybaVystup=0;15 $ChybaVAplikovaniFormatovacichPrikazov=0;16 $CHYBA=0;17 //zadane argumenty18 $BR=0;19 $formatZadany=0;20 $inputZadany=0;21 $outputZadany=0;22 //23 $input=NULL;24 $output=NULL;25 $format=NULL;26 //otvorene subory27 $inputO=0;28 $outputO=0;29 $formatO=0;30 //HELP31 $helpEn=0;32 //premenne do ktorych sa ulozi cesta k suboru33 $fOutput="";34 $fInput="";35 $fFormat=0;36 $STDERR = fopen('php://stderr', 'w+');37 $inputEmpty=0;38///////////////////////////////////////////////////////////////////////////////////////////////////////////////////39///////////////////////////////////////////////////////////////////////////////////////////////////////////////////40///////////////////////////////////////////////////////////////////////////////////////////////////////////////////41///////////////////////////////////////////////////////////////////////////////////////////////////////////////////42///////////////////////////////////////Praca so subormy////////////////////////////////////////////////////////////43///////////////////////////////////////////////////////////////////////////////////////////////////////////////////44///////////////////////////////////////////////////////////////////////////////////////////////////////////////////45///////////////////////////////////////////////////////////////////////////////////////////////////////////////////46 if($argc==2)// za help-om nemoze nasledovat ziadny iny argument47 {48 if($argv[1]=='--help' || $argv[1]=='-h')// vypis napovedy49 {50 $helpEn=1;51 52 Help();53 exit(0);54 }55 }56 if($helpEn==0 && $argc>=1 && $argc<=5)57 {58 if($debug==1)59 {60 echo "\n\npocet argumentov je ".$argc.".\n";61 }62 63 64 for ($cisloArgumentu = 1; $cisloArgumentu < $argc; $cisloArgumentu++) 65 {66 if($debug==1)67 {68 echo "nacitanie " . $cisloArgumentu . " argumentu" . "\n";69 }70 71 if($ChybaArgumentov==1 || $ChybaVstup==1 || $ChybaVystup==1)72 {//nastala chyba, nieje dovod pokracovat dalsimi parametrami 73 if($debug==1)74 {75 echo "nastala chyba, nepokracujeme dalsimi argumentami, spracovanych ".$cisloArgumentu." z ". $argc." \n";76 }77 break;78 }79 elseif($argv[$cisloArgumentu] == '-b' || $argv[$cisloArgumentu] == '--br')80 {81 if($debug==1)82 {83 echo "Je nastavene BR.\n";84 }85 $BR=1;86 }87 elseif(strpos($argv[$cisloArgumentu],'--format=')===0 || strpos($argv[$cisloArgumentu],'-f=')===0)88 {89 //nemusi byt zadany , v tom pripade je: vystup=vstup - $formatO==090 if($debug==1)91 {92 echo "Format:\n";93 }94 95 if($formatZadany!=0)96 {97 $ChybaArgumentov=1;98 if($debug==1)99 {100 echo "Chyba - Format uz bol zadany\n";101 }102 }103 else104 {105 $formatZadany=1;106 //vystrihnutie suboru107 if(strpos($argv[$cisloArgumentu],'--format=')===0)108 {109 $fFormat=substr($argv[$cisloArgumentu],9);110 }111 else //v skratenom tvare -f=112 {113 $fFormat=substr($argv[$cisloArgumentu],3);114 }115 if($debug==1)116 {117 echo "Format: nazov suboru je " . $fFormat . "\n";118 }119 if(file_exists($fFormat))120 {121 $format = fopen($fFormat, "r");//otvorenie suboru pre vstup122 $formatO = 1;123 if(0 == filesize( $fFormat ))//subor je prazdny124 {125 if($debug==1)126 {127 echo "Format: subor je prazdny\n";128 }129 $formatO = 0;130 fclose($format);131 }132 }133 else134 {135 if($debug==1)136 {137 echo "Format: nepodarilo sa otvorit subor\n";138 }139 $ChybaArgumentov=1;140 }141 }142 }143 elseif(strpos($argv[$cisloArgumentu],'--input=')===0 || strpos($argv[$cisloArgumentu],'-i=')===0)144 {145 if($debug==1)146 {147 echo "Input:\n";148 }149 if($inputZadany!=0)150 {151 $ChybaArgumentov=1;152 if($debug==1)153 {154 echo "Chyba - Input uz bol zadany\n";155 }156 }157 else158 {159 $inputZadany=1;160 //vystrihnutie suboru161 if(strpos($argv[$cisloArgumentu],'--input=')===0)162 {163 $fInput=substr($argv[$cisloArgumentu],8);164 }165 else //v skratenom tvare -i=166 {167 $fInput=substr($argv[$cisloArgumentu],3);168 }169 if($debug==1)170 {171 echo "Input: nazov suboru je " . $fInput . "\n";172 }173 if(/*$input = fopen($fInput, "r");*/file_exists($fInput))174 {175 $input = fopen($fInput, "r");//otvorenie suboru pre vstup176 $inputO = 1;177 }178 else179 {180 fwrite($STDERR, "File `".$fInput."' does not exist.\n");181 182 183 $ChybaVstup=1;184 }185 }186 }187 elseif(strpos($argv[$cisloArgumentu],'--output=')===0 || strpos($argv[$cisloArgumentu],'-o=')===0)188 {189 if($debug==1)190 {191 echo "Output:\n";192 }193 if($outputZadany!=0)194 {195 if($debug==1)196 {197 echo "Chyba - Output uz bol zadany\n";198 }199 $ChybaArgumentov=1;200 }201 else202 {203 $outputZadany=1;204 //vystrihnutie suboru205 if(strpos($argv[$cisloArgumentu],'--output=')===0)206 {207 $fOutput=substr($argv[$cisloArgumentu],9);208 }209 else //v skratenom tvare -o=210 {211 $fOutput=substr($argv[$cisloArgumentu],3);212 }213 if($debug==1)214 {215 echo "Output: nazov suboru je " . $fOutput . "\n";216 }217 if((is_writable($fOutput)||!file_exists($fOutput)) && is_dir(dirname($fOutput)))218 {219 $output = fopen($fOutput, "w");220 //;//otvorenie suboru pre vystup221 $outputO = 1;222 }223 else224 {225 if($debug==1)226 {227 echo "Output: nepodarilo sa otvorit subor\n";228 }229 $ChybaVystup=1;230 }231 }232 }233 else234 {235 fwrite($STDERR, "Invalid argument `".$argv[$cisloArgumentu]."'.\n");236 //fwrite($STDERR, "Format table error: Nonexistent parameter `foobar'\n");237 $ChybaArgumentov=1;238 }239 } 240 241 if($ChybaArgumentov==0 && $ChybaVstup==0 && $ChybaVystup==0)//nenastala chyba v argumentoch - mozeme zacat spracovanie :)242 {243 //ak bol zadany vstup, tak sa obsah prekopiruje do premennej244 if($debug==1)245 {246 echo "Vstup " . ($inputZadany==1? "zo suboru" : " z stdin\n");247 }248 if($inputO==1)249 {250 if(filesize($fInput)==0)251 {252 $inputEmpty=1;253 $textNaFormatovanie=" ";254 }255 else256 $textNaFormatovanie= fread($input,filesize($fInput));//file_get_contents($fInput);257 }258 else259 {260 $textNaFormatovanie=file_get_contents("php://stdin");261 }262 263///////////////////////////////////////////////////////////////////////////////////////////////////////////////////264///////////////////////////////////////////////////////////////////////////////////////////////////////////////////265///////////////////////////////////////////////////////////////////////////////////////////////////////////////////266///////////////////////////////////////////////////////////////////////////////////////////////////////////////////267////////////////////////////////////////////Regularny vyraz ///////////////////////////////////////////////////////268///////////////////////////////////////////////////////////////////////////////////////////////////////////////////269///////////////////////////////////////////////////////////////////////////////////////////////////////////////////270///////////////////////////////////////////////////////////////////////////////////////////////////////////////////271 if($formatO==1 )//ak nebol zadany format, obsah vstupneho suboru sa ulozi do vystupneho suboru.Ak bol, tak prejde upravamy272 {273 if($debug==1)274 {275 echo "Spracovanie \n";276 }277 $poleNajdenychPozicia=array();278 $poleNajdenychTyp=array();279 while(!feof($format))//postupne nacitanie riadkov v subore format280 {281 if($debug==1)282 {283 echo "Nacitanie dalsieho formatovacieho riadku. \n";284 }285 //zobereme cely riadok286 $lines = fgets($format);287 if($lines!="\n"&&$lines!="")//musime zistit ci riadok nieje prazdny288 {289 if(strpos($lines, "\t") !== false)//musi obsahovat 290 {291 //Regulárny vyraz292 $line=explode("\t",$lines,2);293 if(count($line)==2 && $line[0]!="" && $line[1]!="")294 {295 $regularExp=$line[0];296 $zoznamFormatovacichPrikazov=explode(',',str_replace(array(" ", "\t","\n"),"",$line[1]));//odstranime medzery a tabulatory a napokon rozdelime na jednotlive prikazy297 if($debug==1)298 {299 echo "Nacitany regularny vyraz: ".$line[0]."\n";300 echo "Formatovacie prikazy:";301 print_r($zoznamFormatovacichPrikazov);302 }303 //zmena regularneho vyrazu zo zadaneho typu na typ php304 $regularExpression="";305 $negacia=0;306 $pocetZatvoriek=0;307 $pomNegacia="";308 $pomPremenna=0;//pouzita na pocet znakov pri negacii (max 1), znak | vynuluje309 $pomNegacia1=0;310 $ppp=0;311 $poleNeg=array();312 $poleZatvoriek=array();313 $pocZnakov=0;314 $lubovolnyZnakVNegacii=0;315 //test ze sa nezakoncuje negaciu316 if(strlen($regularExp)>0&&$regularExp[strlen($regularExp)-1]=='!')317 {318 if(strlen($regularExp)>1&&$regularExp[strlen($regularExp)-2]=='%')319 {320 321 }322 else323 $CHYBA=1;324 }325 for($i=0;$i<strlen($regularExp);$i++)326 {327 $pomNegacia1=$negacia;328 $pomPremenna++;329 //$negacia--;330 $ppp=0;331 $pocZnakov++;332 if($debug==1)333 {334 echo "1. \t".$negacia. "\t". $regularExp[$i] ."\n";335 }336 switch($regularExp[$i])337 {338 case '%':339 $i++;340 if($i<strlen($regularExp))341 {342 switch($regularExp[$i])343 {344 case "s": // - biele znaky ( \t\n\r\f\v)345 $regularExpression=$regularExpression.'\s';346 break;347 case "a": // - jeden libovolný znak //musime testovat ci nieje v negacii - regex preskocime348 $regularExpression=$regularExpression.'(.|\n)';349 if($pomNegacia1%2!=0)350 {351 $lubovolnyZnakVNegacii=1;352 }353 break;354 case "d": // - ÄÃsla od 0 do 9355 $regularExpression=$regularExpression.'[0-9]';356 break;357 case "l": // - malá pÃsmena od a do z358 $regularExpression=$regularExpression.'[a-z]';359 break;360 case "L": // - velká pÃsmena od A do Z361 $regularExpression=$regularExpression.'[A-Z]';362 break;363 case "w": // - malá a velká pÃsmena, tj. (%l|%L)364 $regularExpression=$regularExpression.'([A-Z]|[a-z])';365 break;366 case "W": // - vÅ¡echna pÃsmena a ÄÃsla, tj. (%w|%d)367 $regularExpression=$regularExpression.'([A-Z]|[a-z]|[0-9])';368 break;369 case "t": // - znak tabulátoru (\t)370 $regularExpression=$regularExpression.'\t';371 break;372 case "n": // - znak nového Åádku (\n)373 $regularExpression=$regularExpression.'\n';374 break;375 //specialne symboly376 case ".":377 $regularExpression=$regularExpression.'\.';378 break;379 case "|":380 $regularExpression=$regularExpression.'\|';381 break;382 case "!":383 $regularExpression=$regularExpression.'\!';384 break;385 case "*":386 $regularExpression=$regularExpression.'\*';387 break;388 case "+":389 $regularExpression=$regularExpression.'\+';390 break;391 case "(":392 $regularExpression=$regularExpression.'\(';393 break;394 case ")":395 $regularExpression=$regularExpression.'\)';396 break;397 case "%":398 $regularExpression=$regularExpression.'\%';399 400 break;401 default:402 $CHYBA=1;403 break;404 }405 }406 break;407 408 case ".":409 if($i!=0)//pred * musi byt platny znak , regex sa nemoze zacinat znakom *410 {411 for($counter=$i;;$counter--)412 {413 if($counter==0||in_array($regularExp[$counter-1],array("(","|","!",".")))414 {415 $CHYBA=1;416 break;417 }418 else419 {420 if($regularExp[$counter-1]!=")")421 {422 break; 423 }424 }425 }426 }427 else428 {429 $CHYBA=1;430 }431 $pomPremenna--;432 if($i+1<strlen($regularExp))433 //musim zistit ci po znaku '.' nasleduje alfanumericky znak434 {435 if(!($regularExp[$i+1]!="|"&&$regularExp[$i+1]!="*"&&$regularExp[$i+1]!="+"&&$regularExp[$i+1]!="."))436 {437 $CHYBA=1;438 }439 }440 else441 {442 $CHYBA=1;443 }444 break;445 case "|":446 $regularExpression=$regularExpression."|";447 $pomPremenna--;448 $pocZnakov--;449 if($pocZnakov==0)450 {451 $CHYBA=1;452 }453 $pocZnakov=0;454 if($negacia>0)455 {456 if($pomPremenna==1)457 {458 459 $pomPremenna=0;460 }461 else462 {463 $CHYBA=1;464 }465 }466 break;467 case "\\":468 $regularExpression=$regularExpression."\\\\";469 break;470 case "!":471 $pomPremenna--;472 $pocZnakov--;473 array_push($poleNeg,$pomPremenna+1);474 $pomPremenna=0;475 $ppp=1;476 if($pomNegacia1%2!=0)477 {478 //postupne prejdeme vyraz od konca, ci nemame prazdnu zatvorku479 $prazdna=0;480 for($kk=strlen($regularExpression)-1;;$kk--)481 {482 if($regularExpression[$kk]=='^'&&$regularExpression[$kk-1]=='[')483 {484 if($prazdna==0)//treba vymazat485 {486 $regularExpression=substr_replace($regularExpression,"",$kk-1,2);487 }488 else489 {490 $regularExpression=$regularExpression."]";491 }492 break;493 }494 if($regularExpression[$kk]!=')'&&$regularExpression[$kk]!='(')495 {496 $prazdna++;497 }498 }499 500 }501 else502 {503 $regularExpression=$regularExpression."[^";504 }505 $negacia++;506 $pomNegacia=$pomNegacia."!";507 break;508 case "(":509 $regularExpression=$regularExpression."(";510 $pocetZatvoriek++;511 $pomNegacia=$pomNegacia."(";512 $pomPremenna--;513 array_push($poleZatvoriek,$pocZnakov+1);514 $pocZnakov=0;515 break;516 case ")":517 $regularExpression=$regularExpression.')';518 $pocetZatvoriek--;519 $pomPremenna--;520 $negacia--;521 if($pocZnakov==1)//medzi zatvorkami sa nenachadza ziadny znak (1 kvoli tomu ze aj koniec zatvorky je jeden znak)522 {523 $CHYBA=1;524 }525 $pocZnakov=array_pop($poleZatvoriek);526 if(strlen($pomNegacia)>0&&$pomNegacia[strlen($pomNegacia)-1]=='(')527 //vlozi sa koniec zatvorky528 {529 530 $pomNegacia=substr($pomNegacia, 0, -1);//ostranenie vykricnika531 }532 else533 {534 $CHYBA=1;535 }536 break;537 case "*":538 if($i!=0)//pred * musi byt platny znak , regex sa nemoze zacinat znakom *539 {540 for($counter=$i;;$counter--)541 {542 if($counter==0||in_array($regularExp[$counter-1],array("(","|","!",".")))543 {544 $CHYBA=1;545 break;546 }547 else548 {549 if($regularExp[$counter-1]!=")")550 {551 break; 552 }553 }554 }555 }556 else557 {558 $CHYBA=1;559 }560 while($i+1<strlen($regularExp)&& ($regularExp[$i+1]=='+' || $regularExp[$i+1]=='*'))561 {562 $i++;563 }564 $regularExpression=$regularExpression.'*';565 break;566 case "+":567 if($i!=0)//pred * musi byt platny znak , regex sa nemoze zacinat znakom *568 {569 for($counter=$i;;$counter--)570 {571 if($counter==0||in_array($regularExp[$counter-1],array("(","|","!",".")))572 {573 $CHYBA=1;574 break;575 }576 else577 {578 if($regularExp[$counter-1]!=")")579 {580 break; 581 }582 }583 }584 }585 else586 {587 $CHYBA=1;588 }589 $pocet=1;590 while($i+1<strlen($regularExp)&& ($regularExp[$i+1]=='+' || $regularExp[$i+1]=='*'))591 {592 $i++;593 if($regularExp[$i]=='+' && $pocet!=-1)594 {595 $pocet++;596 }597 if($regularExp[$i]=='*')598 {599 $pocet=-1;600 }601 }602 if($pocet==-1)603 {604 $regularExpression=$regularExpression.'*';605 }606 else607 {608 $regularExpression=$regularExpression."+";609 }610 break;611 default:612 if (ord($regularExp[$i])>=32)613 {614 if((ord($regularExp[$i])>=48 && ord($regularExp[$i])<=57)||(ord($regularExp[$i])>=65&&ord($regularExp[$i])<=90)||(ord($regularExp[$i])>=97&&ord($regularExp[$i])<=122))//znaky 0-9 A-Z a-z615 {616 $regularExpression=$regularExpression.$regularExp[$i];617 }618 else619 {620 $regularExpression=$regularExpression.'\\';621 $regularExpression=$regularExpression.$regularExp[$i];622 }623 }624 break;625 break;626 }627 if($debug==1)628 {629 echo "2. \t".$negacia. "\t". $regularExp[$i] ."\n";630 echo $pomPremenna."\t".$regularExp[$i]."\n";631 }632 while(/*$negacia>0*/$pomNegacia1>=0&&$ppp==0&&strlen($pomNegacia)>0&&$pomNegacia[strlen($pomNegacia)-1]=='!' )633 //vlozi sa koniec zatvorky634 { 635 if($debug==1)636 {637 echo $pomNegacia1;638 }639 //$negacia--;640 if($pomPremenna==1)641 {642 //echo "debug\n";643 $pomNegacia=substr($pomNegacia, 0, -1);//ostranenie vykricnika644 if($pomNegacia1%2==0)645 {646 $regularExpression=$regularExpression."[^";647 }648 else649 {650 //postupne prejdeme vyraz od konca, ci nemame prazdnu zatvorku651 $prazdna=0;652 for($kk=strlen($regularExpression)-1;;$kk--)653 {654 if($regularExpression[$kk]=='^'&&$regularExpression[$kk-1]=='[')655 {656 if($prazdna==0)//treba vymazat657 {658 $regularExpression=substr_replace($regularExpression,"",$kk-1,2);659 }660 else661 {662 $regularExpression=$regularExpression."]";663 }664 break;665 }666 if($regularExpression[$kk]!=')'&&$regularExpression[$kk]!='(')667 {668 $prazdna++;669 }670 }671 }672 //$pomPremenna++;673 $pomPremenna=array_pop($poleNeg);674 675 }676 else 677 {678 $CHYBA=1;//chyba: viac ako 1 znak alebo nebol ziadny zadany priklad:[^(a|bd)],[^(a|)],[^(sd|p)],[^(slovo1|slovo2)]679 }680 $pomNegacia1--;681 }682 if($debug==1)683 {684 echo "regularny vyraz je: ".$regularExpression."\n";685 }686 687 if($pocetZatvoriek<0)//ak je zaporny pocet zatvoriek (bolo viac ukoncenych ako zacatych): (()))688 {689 $CHYBA=1;690 }691 }692 if($pocetZatvoriek!=0 || $pocZnakov==0) //pocet zatvoriek ( a ) musi byt rovnaky a nemoze sa koncit znakom |693 {694 $CHYBA=1;695 }696 //test ci nieje negacia na konci - neukoncena negacia697 if(strlen($regularExpression)>=2&&$regularExpression[strlen($regularExpression)-1]=='^'&&$regularExpression[strlen($regularExpression)-2]=='[')698 {699 $CHYBA=1;700 }701 if($CHYBA==1)702 {703 fwrite($STDERR, "Format table error: Invalid regular expression `".$regularExp."'.\n");704 break;705 }706 707 $regularExpression='/('.$regularExpression.')/';708 if($debug==1)709 {710 echo "Vysledny regularny vyraz je: ".$regularExpression."\n";711 }712///////////////////////////////////////////////////////////////////////////////////////////////////////////////////713///////////////////////////////////////////////////////////////////////////////////////////////////////////////////714///////////////////////////////////////////////////////////////////////////////////////////////////////////////////715///////////////////////////////////////////vyhladavanie reg vyrazu/////////////////////////////////////////////////716///////////////////////////////////////////////////////////////////////////////////////////////////////////////////717///////////////////////////////////////////////////////////////////////////////////////////////////////////////////718///////////////////////////////////////////////////////////////////////////////////////////////////////////////////719///////////////////////////////////////////////////////////////////////////////////////////////////////////////////720 //vyhladavanie - najdeny substring sa ulozi do matches 721 $matches=array(array());//vytvorenie pola pre najdene substringy722 if($lubovolnyZnakVNegacii==0) // lubovolny znak v negacii723 {724 preg_match_all($regularExpression,$textNaFormatovanie,$matches);725 }726 if($debug==1)727 {728 echo "Najdene:";729 print_r($matches);730 }731 //$matches[0]=array_filter($matches[0]);732 //$poleNajdenychPozicia=[];733 //$poleNajdenychTyp=[];734 //do pola sa ulozi cislo kde sa nachadza hladany 735 $poziciaOld=0;736 //cyklus na jednotlive typy formatovania737 $k=0;738 for($i=0;$i<count($matches[0]) && $ChybaVAplikovaniFormatovacichPrikazov==0;$i++)739 {740 if($matches[0][$i]=='')741 {742 $k++;743 }744 else745 {746 if($debug==1)747 {748 echo "Hlada sa string:".$matches[0][$i]."\n";749 }750 //pozicia kde sa nasiel751 752 $pozicia=strpos($textNaFormatovanie,$matches[0][$i], $i-$k==0?0:/*($matches[0][$i]==$matches[0][$i-$k-1]?(*/$poziciaOld+strlen($matches[0][$i-$k-1])/*):$poziciaOld)*/);753 /*if($poziciaOld!=0 &&( ($matches[0][$i]==$matches[0][$i-$k-1]?)-$poziciaOld<strlen($matches[0][$i-1])))//riesi prekryvanie toho isteho reg vyrazu754 {755 $poziciaOld=$pozicia;756 continue;757 }*/758 $poziciaOld=$pozicia;759 $position=0;760 $k=0;761 if($debug==1)762 {763 echo "Najdene na pozicii:".$pozicia."\n";764 }765 766 for($j=0;$j<count($zoznamFormatovacichPrikazov);$j++)767 {768 //zaciatok769 if(count($poleNajdenychPozicia)!=0)770 for(;$position<count($poleNajdenychPozicia);$position++)771 {772 if(($pozicia<$poleNajdenychPozicia[$position]))773 {774 775 break;776 }777 } 778 array_splice($poleNajdenychPozicia,$position,0,$pozicia);779 //nasleduje switch v ktorom sa urci ze co sa ma vlozit780 781 if($debug==1)782 {783 echo "Najdene na pozicii:".$pozicia. "-nemoze sa zmenit\n";784 }785 if($debug==1)786 {787 echo "aplikovanie formatovacieho prikazu:" . $zoznamFormatovacichPrikazov[$j]. "\n";788 }789 switch($zoznamFormatovacichPrikazov[$j])790 {791 case "bold":792 array_splice($poleNajdenychTyp,$position,0,"<b>");//vlozi sa zaciatok tagu793 break;794 case "italic":795 array_splice($poleNajdenychTyp,$position,0,"<i>");//vlozi sa zaciatok tagu796 break;797 case "underline":798 array_splice($poleNajdenychTyp,$position,0,"<u>");//vlozi sa zaciatok tagu799 break;800 case "teletype":801 array_splice($poleNajdenychTyp,$position,0,"<tt>");//vlozi sa zaciatok tagu802 break;803 default:804 if(strpos($zoznamFormatovacichPrikazov[$j],'size:')===0)805 {806 $cislo=substr($zoznamFormatovacichPrikazov[$j],5);807 if(strlen($cislo)==1)//cislo>=1 &&cislo<=7808 {809 if($cislo=='1'||$cislo=='2'||$cislo=='3'||$cislo=='4'||$cislo=='5'||$cislo=='6'||$cislo=='7')810 {811 array_splice($poleNajdenychTyp,$position,0,"<font size=".$cislo.">");812 }813 else814 {815 $ChybaVAplikovaniFormatovacichPrikazov=1;816 817 fwrite($STDERR, "Format table error: Invalid size `".$cislo."'.\n");818 819 }820 }821 else822 {823 fwrite($STDERR, "Format table error: Invalid size `".$cislo.".'\n");824 //chyba825 $ChybaVAplikovaniFormatovacichPrikazov=1;826 if($debug==1)827 {828 echo "CHYBA: Zvolena velkost ma viac ako 1 znak\n";829 }830 }831 }832 elseif(strpos($zoznamFormatovacichPrikazov[$j],'color:')===0)833 {834 $hex=substr($zoznamFormatovacichPrikazov[$j],6);835 //echo "\"".$hex."\"\n";836 if(strlen($hex)==6)//hex>=000000 && hex<=FFFFFF837 {838 839 foreach(str_split($hex) as $num)840 {841 if($num=='0'||$num=='1'||$num=='2'||$num=='3'||$num=='4'||$num=='5'||$num=='6'||$num=='7'||$num=='8'||$num=='9'||$num=='A'||$num=='B'||$num=='C'||$num=='D'||$num=='E'||$num=='F'||$num=='a'||$num=='b'||$num=='c'||$num=='d'||$num=='e'||$num=='f')842 {843 844 }845 else846 {847 $ChybaVAplikovaniFormatovacichPrikazov=1;848 if($debug==1)849 {850 echo "CHYBA: Zvolena farba je mimo interval 000000 - FFFFFF\n";851 }852 }853 }854 if($ChybaVAplikovaniFormatovacichPrikazov==0)855 {856 857 array_splice($poleNajdenychTyp,$position,0,"<font color=#".$hex.">");858 }859 }860 else861 {862 //chyba863 $ChybaVAplikovaniFormatovacichPrikazov=1;864 if($debug==1)865 {866 echo "CHYBA: Zvolena farba ma viac ako 6 znakov\n";867 }868 }869 }870 else871 {872 //chyba873 fwrite($STDERR, "Format table error: Nonexistent parameter `".$zoznamFormatovacichPrikazov[$j].".'\n");874 $ChybaVAplikovaniFormatovacichPrikazov=1;875 if($debug==1)876 {877 echo "CHYBA:Chybny formatovaci prikaz\n";878 }879 }880 break;881 }882 883 //koniec884 $poziciaA=$pozicia+strlen($matches[0][$i]);885 for($position=count($poleNajdenychPozicia)-1;$position>=0;$position--)886 {887 if($poziciaA>$poleNajdenychPozicia[$position])888 {889 $position++;890 break;891 }892 } 893 array_splice($poleNajdenychPozicia,$position,0,$poziciaA);894 switch($zoznamFormatovacichPrikazov[$j])895 {896 case "bold":897 array_splice($poleNajdenychTyp,$position,0,"</b>");//vlozi sa zaciatok tagu898 break;899 case "italic":900 array_splice($poleNajdenychTyp,$position,0,"</i>");//vlozi sa zaciatok tagu901 break;902 case "underline":903 array_splice($poleNajdenychTyp,$position,0,"</u>");//vlozi sa zaciatok tagu904 break;905 case "teletype":906 array_splice($poleNajdenychTyp,$position,0,"</tt>");//vlozi sa zaciatok tagu907 break;908 default:909 if(strpos($zoznamFormatovacichPrikazov[$j],'size:')===0)910 {911 $cislo=substr($zoznamFormatovacichPrikazov[$j],5);912 if(strlen($cislo)==1)//cislo>=0 &&cislo<=7913 {914 if($cislo=='1'||$cislo=='2'||$cislo=='3'||$cislo=='4'||$cislo=='5'||$cislo=='6'||$cislo=='7')915 {916 array_splice($poleNajdenychTyp,$position,0,"</font>");917 }918 else919 {920 $ChybaVAplikovaniFormatovacichPrikazov=1;921 if($debug==1)922 {923 echo "CHYBA: Zvolena velkost je mimo interval 0 - 7\n";924 }925 }926 }927 else928 {929 //chyba930 $ChybaVAplikovaniFormatovacichPrikazov=1;931 if($debug==1)932 {933 echo "CHYBA: Zvolena velkost ma viac ako 1 znak\n";934 }935 }936 }937 elseif(strpos($zoznamFormatovacichPrikazov[$j],'color:')===0)938 {939 $hex=substr($zoznamFormatovacichPrikazov[$j],6);940 if(strlen($hex)==6)//hex>=000000 && hex<=FFFFFF941 {942 943 foreach(str_split($hex) as $num)944 {945 if($num=='0'||$num=='1'||$num=='2'||$num=='3'||$num=='4'||$num=='5'||$num=='6'||$num=='7'||$num=='8'||$num=='9'||$num=='A'||$num=='B'||$num=='C'||$num=='D'||$num=='E'||$num=='F'||$num=='a'||$num=='b'||$num=='c'||$num=='d'||$num=='e'||$num=='f')946 {947 948 }949 else950 {951 $ChybaVAplikovaniFormatovacichPrikazov=1;952 if($debug==1)953 {954 echo "CHYBA: Zvolena farba je mimo interval 000000 - FFFFFF\n";955 }956 }957 }958 if($ChybaVAplikovaniFormatovacichPrikazov==0)959 {960 961 array_splice($poleNajdenychTyp,$position,0,"</font>");962 }963 }964 else965 {966 //chyba967 $ChybaVAplikovaniFormatovacichPrikazov=1;968 if($debug==1)969 {970 echo "CHYBA: Zvolena farba ma viac ako 6 znakov\n";971 }972 }973 }974 else975 {976 //chyba977 $ChybaVAplikovaniFormatovacichPrikazov=1;978 if($debug==1)979 {980 echo "CHYBA:Chybny formatovaci prikaz\n";981 }982 }983 break;984 }985 if($debug==1 && $ChybaVAplikovaniFormatovacichPrikazov==0)986 {987 echo "Aplikovanie uspesne\n";988 }989 if($debug==1)990 {991 print_r($poleNajdenychPozicia);992 print_r($poleNajdenychTyp);993 }994 }995 } 996 }997 if(count($matches[0])==0)//musime otestovat ci sa na pozicii formatovania nachadza validny typ998 {999 for($j=0;$j<count($zoznamFormatovacichPrikazov);$j++)1000 {1001 switch($zoznamFormatovacichPrikazov[$j])1002 {1003 case "bold":1004 break;1005 case "italic":1006 break;1007 case "underline":1008 break;1009 case "teletype":1010 break;1011 default:1012 if(strpos($zoznamFormatovacichPrikazov[$j],'size:')===0)1013 {1014 $cislo=substr($zoznamFormatovacichPrikazov[$j],5);1015 if(strlen($cislo)==1)//cislo>=0 &&cislo<=71016 {1017 if($cislo=='1'||$cislo=='2'||$cislo=='3'||$cislo=='4'||$cislo=='5'||$cislo=='6'||$cislo=='7')1018 {1019 1020 }1021 else1022 {1023 $ChybaVAplikovaniFormatovacichPrikazov=1;1024 fwrite($STDERR, "Format table error: Invalid size `".$cislo."'.\n");1025 }1026 }1027 else1028 {1029 //chyba1030 $ChybaVAplikovaniFormatovacichPrikazov=1;1031 fwrite($STDERR, "Format table error: Invalid size `".$cislo."'.\n");1032 }1033 }1034 elseif(strpos($zoznamFormatovacichPrikazov[$j],'color:')===0)1035 {1036 $hex=substr($zoznamFormatovacichPrikazov[$j],6);1037 if(strlen($hex)==6)//hex>=000000 && hex<=FFFFFF1038 {1039 1040 foreach(str_split($hex) as $num)1041 {1042 if($num=='0'||$num=='1'||$num=='2'||$num=='3'||$num=='4'||$num=='5'||$num=='6'||$num=='7'||$num=='8'||$num=='9'||$num=='A'||$num=='B'||$num=='C'||$num=='D'||$num=='E'||$num=='F'||$num=='a'||$num=='b'||$num=='c'||$num=='d'||$num=='e'||$num=='f')1043 {1044 1045 }1046 else1047 {1048 $ChybaVAplikovaniFormatovacichPrikazov=1;1049 //fwrite($STDERR, "Format table error: Invalid color `".$hex."'.\n");1050 }1051 }1052 if($ChybaVAplikovaniFormatovacichPrikazov==0)1053 {1054 1055 //array_splice($poleNajdenychTyp,$position,0,"</font>");1056 }1057 else1058 {1059 fwrite($STDERR, "Format table error: Invalid color `".$hex."'.\n");1060 }1061 }1062 else1063 {1064 //chyba1065 $ChybaVAplikovaniFormatovacichPrikazov=1;1066 fwrite($STDERR, "Format table error: Invalid color `".$hex."'.\n");1067 }1068 }1069 else1070 {1071 //chyba1072 $ChybaVAplikovaniFormatovacichPrikazov=1;1073 1074 fwrite($STDERR, "Format table error: Nonexistent parameter `".$zoznamFormatovacichPrikazov[$j]."'.\n");1075 }1076 break;1077 }1078 }1079 }1080 //po dokonceny formatovacieho pola mozme vlozit jednotlive formaty1081 1082 }1083 else1084 {1085 //chyba1086 $ChybaVAplikovaniFormatovacichPrikazov=1;1087 if($debug==1)1088 {1089 echo "CHYBA:Riadok vo formatovacom subore neobsahuje \\t\n";1090 }1091 }1092 }1093 else1094 {1095 //chyba1096 $ChybaVAplikovaniFormatovacichPrikazov=1;1097 if($debug==1)1098 {1099 echo "CHYBA:Riadok vo formatovacom subore neobsahuje \\t\n";1100 }1101 }1102 }1103 else1104 {1105 if($debug==1)1106 {1107 echo "Riadok je prazdny\n";1108 }1109 }1110 }1111///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1112///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1113///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1114///////////////////////////////////////////vkladanie formatovacich pravidiel///////////////////////////////////////1115///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1116///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1117///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1118///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1119 //finalne vlozenie formatovacich pravidiel do textNaFormatovanie1120 if($debug==1)1121 {1122 print_r($poleNajdenychPozicia);1123 print_r($poleNajdenychTyp);1124 }1125 if(count($poleNajdenychTyp)==count($poleNajdenychPozicia))1126 {1127 for($i=count($poleNajdenychPozicia)-1;$i>=0;$i--)1128 {1129 $textNaFormatovanie=substr_replace($textNaFormatovanie, $poleNajdenychTyp[$i], $poleNajdenychPozicia[$i], 0);1130 }1131 }1132 }1133///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1134///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1135///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1136///////////////////////////////////////////<br />//////////////////////////////////////////////////////////////////1137///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1138///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1139///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1140///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1141 if($BR==1)1142 {1143 /*while ($ch=fgets($input)) //prekopirovanie obsahu input do output1144 {1145 fputs($output, $BR==1 ? $ch : $ch . "<br />");1146 //Ak je povolene BR , tak sa za kazdym riadkom vlozi <br />1147 }*/1148 if($debug==1)1149 {1150 echo "\n\nBR: na koniec riadku sa prida <br />\n\n";1151 }1152 1153 $textNaFormatovanie=str_replace("\n","<br />\n",$textNaFormatovanie);1154 1155 1156 }1157 if($debug==1)1158 {1159 echo "\n\nVypis " . ($outputZadany==1? "do suboru\n" : ":\n");1160 }1161 if($debug==1)1162 {1163 $textNaFormatovanie="<!DOCTYPE html>\n<html>\n<head>\n<title>Page Title</title>\n</head>\n<body>".$textNaFormatovanie."</body>\n</html>";1164 }1165 1166 1167 if($ChybaVAplikovaniFormatovacichPrikazov==0 && $CHYBA==0&&$inputEmpty==0)//ak nenastala chyba pri spracovani1168 {1169 if($outputO==1)//ak bol zadany vystup tak sa vypise do suboru, inak sa vypise na standardny vystup1170 {1171 fwrite($output,$textNaFormatovanie);1172 }1173 else1174 {1175 echo $textNaFormatovanie;1176 }1177 }1178 1179 1180 }1181///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1182///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1183///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1184//////////////////////////////////////////uzatvaranie suborov//////////////////////////////////////////////////////1185///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1186///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1187///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1188///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1189 if($debug==1)1190 {1191 echo "\nUzatvaranie suborov\n";1192 }1193 //zatvorenie suborov1194 if($outputO==1)1195 fclose($output);1196 if($inputO==1)1197 fclose($input);1198 if($formatO==1)1199 fclose($format);1200 }1201 else1202 {1203 $ChybaArgumentov=1;1204 }1205///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1206///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1207///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1208////////////////////////////////////////navratove hodnoty chyb/////////////////////////////////////////////////////1209///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1210///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1211///////////////////////////////////////////////////////////////////////////////////////////////////////////////////1212/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1213 if($ChybaArgumentov==1)//nastala chyba v argumentoch1214 {1215 //fwrite($STDERR, "CHYBA: Chyba v argumentoch.\n");1216 exit(1);1217 }1218 if($ChybaVstup==1)//chyba v otvoreni vstupneho suboru1219 {1220 //fwrite($STDERR, "CHYBA: Nepodarilo sa otvorit vstupny subor\n");1221 exit(2);1222 }1223 if($ChybaVystup==1)//chyba v otvoreni vstupneho suboru1224 {1225 fwrite($STDERR, "Output directory does not exist.\n");1226 exit(3);1227 }1228 if($ChybaVAplikovaniFormatovacichPrikazov==1)1229 {1230 //fwrite($STDERR, "CHYBA: Chyba vo formatovacom subore\n");1231 exit(4);1232 }1233 if($CHYBA==1)1234 {1235 //fwrite($STDERR, "CHYBA: Chyba v regularnom vyraze\n");1236 exit(4);1237 }1238 exit(0);1239?>...
default.php
Source:default.php
1<?php2return array (3 0 => 4 ezcDocumentPcssLayoutDirective::__set_state(array(5 'regularExpression' => NULL,6 'address' => 7 array (8 0 => 'article',9 ),10 'formats' => 11 array (12 'font-size' => '12pt',13 'font-family' => 'sans-serif',14 'font-weight' => 'normal',15 'font-style' => 'normal',16 'line-height' => '1.4',17 'text-align' => 'left',18 'text-decoration' => 'none',19 'background-color' => 'transparent',20 'border' => '0 solid #000',21 'color' => '#2e3436',22 'text-columns' => '1',23 'text-column-spacing' => '10mm',24 'direction' => 'ltr',25 'padding' => '0mm',26 'margin' => '0mm',27 'orphans' => '3',28 'widows' => '3',29 ),30 'file' => 'style/default.css',31 'line' => 1,32 'position' => 8,33 )),34 1 => 35 ezcDocumentPcssLayoutDirective::__set_state(array(36 'regularExpression' => NULL,37 'address' => 38 array (39 0 => 'page',40 ),41 'formats' => 42 array (43 'page-size' => 'A4',44 'page-orientation' => 'portrait',45 'padding' => '22mm 16mm',46 'margin' => '0mm',47 ),48 'file' => 'style/default.css',49 'line' => 28,50 'position' => 6,51 )),52 2 => 53 ezcDocumentPcssLayoutDirective::__set_state(array(54 'regularExpression' => NULL,55 'address' => 56 array (57 0 => 'para',58 ),59 'formats' => 60 array (61 'border' => 'none',62 'margin' => '3mm 0mm 1mm 0mm',63 'padding' => '0mm',64 ),65 'file' => 'style/default.css',66 'line' => 38,67 'position' => 6,68 )),69 3 => 70 ezcDocumentPcssLayoutDirective::__set_state(array(71 'regularExpression' => NULL,72 'address' => 73 array (74 0 => 'emphasis',75 ),76 'formats' => 77 array (78 'font-weight' => 'bold',79 ),80 'file' => 'style/default.css',81 'line' => 44,82 'position' => 10,83 )),84 4 => 85 ezcDocumentPcssLayoutDirective::__set_state(array(86 'regularExpression' => NULL,87 'address' => 88 array (89 0 => 'ulink',90 ),91 'formats' => 92 array (93 'text-decoration' => 'underline',94 'color' => '#204a87',95 ),96 'file' => 'style/default.css',97 'line' => 48,98 'position' => 7,99 )),100 5 => 101 ezcDocumentPcssLayoutDirective::__set_state(array(102 'regularExpression' => NULL,103 'address' => 104 array (105 0 => 'link',106 ),107 'formats' => 108 array (109 'text-decoration' => 'underline',110 'color' => '#204a87',111 ),112 'file' => 'style/default.css',113 'line' => 53,114 'position' => 6,115 )),116 6 => 117 ezcDocumentPcssLayoutDirective::__set_state(array(118 'regularExpression' => NULL,119 'address' => 120 array (121 0 => 'title',122 ),123 'formats' => 124 array (125 'font-family' => 'serif',126 'font-weight' => 'bold',127 'color' => '#000000',128 ),129 'file' => 'style/default.css',130 'line' => 58,131 'position' => 7,132 )),133 7 => 134 ezcDocumentPcssLayoutDirective::__set_state(array(135 'regularExpression' => NULL,136 'address' => 137 array (138 0 => 'title',139 ),140 'formats' => 141 array (142 'font-size' => '32pt',143 ),144 'file' => 'style/default.css',145 'line' => 64,146 'position' => 7,147 )),148 8 => 149 ezcDocumentPcssLayoutDirective::__set_state(array(150 'regularExpression' => NULL,151 'address' => 152 array (153 0 => 'section',154 1 => '> title',155 ),156 'formats' => 157 array (158 'font-size' => '24pt',159 'text-columns' => '1',160 'margin' => '10mm 0mm 4mm 0mm',161 ),162 'file' => 'style/default.css',163 'line' => 68,164 'position' => 17,165 )),166 9 => 167 ezcDocumentPcssLayoutDirective::__set_state(array(168 'regularExpression' => NULL,169 'address' => 170 array (171 0 => 'section',172 1 => '> section',173 2 => '> title',174 ),175 'formats' => 176 array (177 'font-size' => '20pt',178 'text-columns' => '1',179 ),180 'file' => 'style/default.css',181 'line' => 74,182 'position' => 27,183 )),184 10 => 185 ezcDocumentPcssLayoutDirective::__set_state(array(186 'regularExpression' => NULL,187 'address' => 188 array (189 0 => 'section',190 1 => '> section',191 2 => '> section',192 3 => '> title',193 ),194 'formats' => 195 array (196 'font-size' => '18pt',197 ),198 'file' => 'style/default.css',199 'line' => 79,200 'position' => 37,201 )),202 11 => 203 ezcDocumentPcssLayoutDirective::__set_state(array(204 'regularExpression' => NULL,205 'address' => 206 array (207 0 => 'section',208 1 => '> section',209 2 => '> section',210 3 => '> section',211 4 => '> title',212 ),213 'formats' => 214 array (215 'font-size' => '16pt',216 ),217 'file' => 'style/default.css',218 'line' => 83,219 'position' => 47,220 )),221 12 => 222 ezcDocumentPcssLayoutDirective::__set_state(array(223 'regularExpression' => NULL,224 'address' => 225 array (226 0 => 'section',227 1 => '> section',228 2 => '> section',229 3 => '> section',230 4 => '> section',231 5 => '> title',232 ),233 'formats' => 234 array (235 'font-size' => '14pt',236 ),237 'file' => 'style/default.css',238 'line' => 87,239 'position' => 57,240 )),241 13 => 242 ezcDocumentPcssLayoutDirective::__set_state(array(243 'regularExpression' => NULL,244 'address' => 245 array (246 0 => 'section',247 1 => '> section',248 2 => '> section',249 3 => '> section',250 4 => '> section',251 5 => '> section',252 6 => '> title',253 ),254 'formats' => 255 array (256 'font-size' => '12pt',257 ),258 'file' => 'style/default.css',259 'line' => 91,260 'position' => 67,261 )),262 14 => 263 ezcDocumentPcssLayoutDirective::__set_state(array(264 'regularExpression' => NULL,265 'address' => 266 array (267 0 => 'literallayout',268 ),269 'formats' => 270 array (271 'border' => '1mm solid #d3d7d5',272 'background-color' => '#f5f5f6',273 'padding' => '1',274 'font-size' => '10pt',275 'font-family' => 'monospace',276 ),277 'file' => 'style/default.css',278 'line' => 95,279 'position' => 15,280 )),281 15 => 282 ezcDocumentPcssLayoutDirective::__set_state(array(283 'regularExpression' => NULL,284 'address' => 285 array (286 0 => 'varlistentry',287 1 => '> term',288 ),289 'formats' => 290 array (291 'font-weight' => 'bold',292 ),293 'file' => 'style/default.css',294 'line' => 103,295 'position' => 21,296 )),297 16 => 298 ezcDocumentPcssLayoutDirective::__set_state(array(299 'regularExpression' => NULL,300 'address' => 301 array (302 0 => 'varlistentry',303 1 => '> listitem',304 ),305 'formats' => 306 array (307 'padding-left' => '5mm',308 'margin-bottom' => '3mm',309 ),310 'file' => 'style/default.css',311 'line' => 107,312 'position' => 25,313 )),314 17 => 315 ezcDocumentPcssLayoutDirective::__set_state(array(316 'regularExpression' => NULL,317 'address' => 318 array (319 0 => 'orderedlist',320 1 => '> listitem',321 ),322 'formats' => 323 array (324 'padding-left' => '10mm',325 'margin-bottom' => '3mm',326 ),327 'file' => 'style/default.css',328 'line' => 112,329 'position' => 24,330 )),331 18 => 332 ezcDocumentPcssLayoutDirective::__set_state(array(333 'regularExpression' => NULL,334 'address' => 335 array (336 0 => 'itemizedlist',337 1 => '> listitem',338 ),339 'formats' => 340 array (341 'padding-left' => '10mm',342 'margin-bottom' => '3mm',343 ),344 'file' => 'style/default.css',345 'line' => 117,346 'position' => 25,347 )),348 19 => 349 ezcDocumentPcssLayoutDirective::__set_state(array(350 'regularExpression' => NULL,351 'address' => 352 array (353 0 => 'listitem',354 1 => '> para',355 ),356 'formats' => 357 array (358 'margin' => '0mm 0mm 4mm 0mm',359 ),360 'file' => 'style/default.css',361 'line' => 122,362 'position' => 17,363 )),364 20 => 365 ezcDocumentPcssLayoutDirective::__set_state(array(366 'regularExpression' => NULL,367 'address' => 368 array (369 0 => 'blockquote',370 ),371 'formats' => 372 array (373 'margin' => '2mm 0mm 4mm 10mm',374 ),375 'file' => 'style/default.css',376 'line' => 126,377 'position' => 12,378 )),379 21 => 380 ezcDocumentPcssLayoutDirective::__set_state(array(381 'regularExpression' => NULL,382 'address' => 383 array (384 0 => 'blockquote',385 1 => '> attribution',386 ),387 'formats' => 388 array (389 'margin' => '1mm 0mm 1mm 5mm',390 'font-style' => 'italic',391 ),392 'file' => 'style/default.css',393 'line' => 130,394 'position' => 26,395 )),396 22 => 397 ezcDocumentPcssLayoutDirective::__set_state(array(398 'regularExpression' => NULL,399 'address' => 400 array (401 0 => 'table',402 ),403 'formats' => 404 array (405 'margin' => '2mm 0mm',406 'border' => '1px solid #babdb6',407 'padding' => '0px 1px 1px 0px',408 ),409 'file' => 'style/default.css',410 'line' => 135,411 'position' => 7,412 )),413 23 => 414 ezcDocumentPcssLayoutDirective::__set_state(array(415 'regularExpression' => NULL,416 'address' => 417 array (418 0 => 'table',419 1 => 'entry',420 ),421 'formats' => 422 array (423 'margin' => '1px 0px 0px 1px',424 'border' => '1px solid #d3d7d5',425 'padding' => '1mm',426 ),427 'file' => 'style/default.css',428 'line' => 141,429 'position' => 13,430 )),431 24 => 432 ezcDocumentPcssLayoutDirective::__set_state(array(433 'regularExpression' => NULL,434 'address' => 435 array (436 0 => 'table',437 1 => 'thead',438 2 => 'entry',439 ),440 'formats' => 441 array (442 'font-weight' => 'bold',443 ),444 'file' => 'style/default.css',445 'line' => 147,446 'position' => 19,447 )),448);449?>...
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Framework/Assert/Functions.php';2require_once 'PHPUnit/Framework/Assert/Functions.php';3require_once 'PHPUnit/Framework/Assert/Functions.php';4require_once 'PHPUnit/Framework/Assert/Functions.php';5require_once 'PHPUnit/Framework/Assert/Functions.php';6require_once 'PHPUnit/Framework/Assert/Functions.php';7require_once 'PHPUnit/Framework/Assert/Functions.php';8require_once 'PHPUnit/Framework/Assert/Functions.php';9require_once 'PHPUnit/Framework/Assert/Functions.php';10require_once 'PHPUnit/Framework/Assert/Functions.php';11require_once 'PHPUnit/Framework/Assert/Functions.php';12require_once 'PHPUnit/Framework/Assert/Functions.php';13require_once 'PHPUnit/Framework/Assert/Functions.php';14require_once 'PHPUnit/Framework/Assert/Functions.php';15require_once 'PHPUnit/Framework/Assert/Functions.php';16require_once 'PHPUnit/Framework/Assert/Functions.php';17require_once 'PHPUnit/Framework/Assert/Functions.php';18require_once 'PHPUnit/Framework/Assert/Functions.php';19require_once 'PHPUnit/Framework/Assert/Functions.php';20require_once 'PHPUnit/Framework/Assert/Functions.php';21require_once 'PHPUnit/Framework/Assert/Functions.php';
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Extensions/PhptTestSuite.php';2require_once 'PHPUnit/Extensions/PhptTestCase.php';3require_once 'PHPUnit/Extensions/PhptTestCase/Command.php';4require_once 'PHPUnit/Extensions/PhptTestCase/Command/Factory.php';5require_once 'PHPUnit/Extensions/PhptTestCase/Command/Factory/Default.php';6require_once 'PHPUnit/Extensions/PhptTestCase/Command/Factory/Windows.php';7require_once 'PHPUnit/Extensions/PhptTestCase/Command/Result.php';8require_once 'PHPUnit/Extensions/PhptTestCase/Command/Result/Factory.php';9require_once 'PHPUnit/Extensions/PhptTestCase/Command/Result/Factory/Default.php';10require_once 'PHPUnit/Extensions/PhptTestCase/Command/Result/Factory/Windows.php';11require_once 'PHPUnit/Extensions/PhptTestCase/Command/Result/Windows.php';12require_once 'PHPUnit/Extensions/PhptTestCase/Command/Windows.php';13require_once 'PHPUnit/Extensions/PhptTestCase/Factory.php';14require_once 'PHPUnit/Extensions/PhptTestCase/Factory/Default.php';15require_once 'PHPUnit/Extensions/PhptTestCase/Factory/Windows.php';16require_once 'PHPUnit/Extensions/PhptTestCase/Invocation.php';17require_once 'PHPUnit/Extensions/PhptTestCase/Invocation/Factory.php';18require_once 'PHPUnit/Extensions/PhptTestCase/Invocation/Factory/Default.php';19require_once 'PHPUnit/Extensions/PhptTestCase/Invocation/Factory/Windows.php';20require_once 'PHPUnit/Extensions/PhptTestCase/Invocation/Windows.php';21require_once 'PHPUnit/Extensions/PhptTestCase/Result.php';22require_once 'PHPUnit/Extensions/PhptTestCase/Result/Factory.php';23require_once 'PHPUnit/Extensions/PhptTestCase/Result/Factory/Default.php';24require_once 'PHPUnit/Extensions/PhptTestCase/Result/Factory/Windows.php';25require_once 'PHPUnit/Extensions/PhptTestCase/Result/Windows.php';26require_once 'PHPUnit/Extensions/PhptTestCase/Windows.php';27require_once 'PHPUnit/Extensions/PhptTestCase/Windows/Result.php';28require_once 'PHPUnit/Extensions/PhptTestCase/Windows/Result/Factory.php';29require_once 'PHPUnit/Extensions/PhptTestCase/Windows/Result/Factory/Default.php';30require_once 'PHPUnit/Extensions/PhptTestCase/Windows/Result/Factory/Windows.php';
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Framework.php';2require_once 'PHPUnit/Extensions/PhptTestCase.php';3require_once 'PHPUnit/Extensions/PhptTestCase/RegularExpression.php';4{5 public function testRegularExpression()6 {7 $regexp = new PHPUnit_Extensions_PhptTestCase_RegularExpression();8 $this->assertTrue($regexp->matches('1234567890', '/1234567890/'));9 }10}11require_once 'PHPUnit/Framework.php';12require_once 'PHPUnit/Extensions/PhptTestCase.php';13require_once 'PHPUnit/Extensions/PhptTestCase/RegularExpression.php';14{15 public function testRegularExpression()16 {17 $regexp = new PHPUnit_Extensions_PhptTestCase_RegularExpression();18 $this->assertTrue($regexp->matches('1234567890', '/1234567890/'));19 }20}21require_once 'PHPUnit/Framework.php';22require_once 'PHPUnit/Extensions/PhptTestCase.php';23require_once 'PHPUnit/Extensions/PhptTestCase/RegularExpression.php';24{25 public function testRegularExpression()26 {27 $regexp = new PHPUnit_Extensions_PhptTestCase_RegularExpression();28 $this->assertTrue($regexp->matches('1234567890', '/1234567890/'));29 }30}31require_once 'PHPUnit/Autoload.php';32require_once 'PHPUnit/TextUI/TestRunner.php';33require_once 'PHPUnit/Util/Filter.php';34PHPUnit_Util_Filter::addFileToFilter(__FILE__);35{36 public static function suite()37 {38 $suite = new PHPUnit_Framework_TestSuite('PHPUnit');39 $suite->addTestFile('1.php');40 $suite->addTestFile('2.php');41 $suite->addTestFile('3.php');42 return $suite;43 }44}45PHPUnit_TextUI_TestRunner::run(self::suite());
RegularExpression
Using AI Code Generation
1use PHPUnit\Framework\TestCase;2{3 public function testMatch()4 {5 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');6 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc 123');7 }8}9use PHPUnit\Framework\TestCase;10{11 public function testMatch()12 {13 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');14 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc 123');15 }16}17use PHPUnit\Framework\TestCase;18{19 public function testMatch()20 {21 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');22 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc 123');23 }24}25use PHPUnit\Framework\TestCase;26{27 public function testMatch()28 {29 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');30 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc 123');31 }32}33use PHPUnit\Framework\TestCase;34{35 public function testMatch()36 {37 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');38 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc 123');39 }40}41use PHPUnit\Framework\TestCase;42{43 public function testMatch()44 {45 $this->assertRegExp('/^[a-z0-9]+$/i', 'Abc123');46 $this->assertNotRegExp('/^[a-z0-9]+$/i', 'Abc
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Autoload.php';2{3 public function testRegEx()4 {5 $this->assertRegExp('/^foo/', 'foobar');6 }7}
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Framework.php';2require_once 'RegularExpression.php';3{4 public function testRegularExpression()5 {6 $this->assertRegExp('/^(\d{4})-(\d{2})-(\d{2})$/', '2012-01-01');7 }8}9OK (1 test, 1 assertion)10OK (1 test, 1 assertion)11require_once 'PHPUnit/Framework.php';12require_once 'RegularExpression.php';13{14 public function testRegularExpression()15 {16 $this->assertRegExp('/^(\d{4})-(\d{2})-(\d{2})$/', '2012-01-01');17 }18}19OK (1 test, 1 assertion)20OK (1 test, 1 assertion)21require_once 'PHPUnit/Framework.php';22require_once 'RegularExpression.php';23{
RegularExpression
Using AI Code Generation
1require_once 'PHPUnit/Framework.php';2require_once 'PHPUnit/Util/RegularExpression.php';3{4 public function testMatches()5 {6 $pattern = '/^#.*$/';7 $string = '#comment';8 $this->assertThat($string, new PHPUnit_Util_RegularExpression($pattern));9 }10}11require_once 'PHPUnit/Framework.php';12require_once 'PHPUnit/Util/RegularExpression.php';13{14 public function testMatches()15 {16 $pattern = '/^#.*$/';17 $string = '#comment';18 $this->assertThat($string, new PHPUnit_Util_RegularExpression($pattern));19 }20}21require_once 'PHPUnit/Framework.php';22require_once 'PHPUnit/Util/RegularExpression.php';23{24 public function testMatches()25 {26 $pattern = '/^#.*$/';27 $string = '#comment';28 $this->assertThat($string, new PHPUnit_Util_RegularExpression($pattern));29 }30}31require_once 'PHPUnit/Framework.php';32require_once 'PHPUnit/Util/RegularExpression.php';33{34 public function testMatches()35 {36 $pattern = '/^#.*$/';37 $string = '#comment';38 $this->assertThat($string, new PHPUnit_Util_RegularExpression($pattern));39 }40}41require_once 'PHPUnit/Framework.php';42require_once 'PHPUnit/Util/RegularExpression.php';43{44 public function testMatches()45 {46 $pattern = '/^#.*$/';47 $string = '#comment';48 $this->assertThat($string, new PHPUnit_Util_RegularExpression($pattern));49 }50}51require_once 'PHPUnit/Framework.php';52require_once 'PHPUnit/Util/RegularExpression.php';53{54 public function testMatches()55 {56 $pattern = '/^#.*$/';
RegularExpression
Using AI Code Generation
1use PHPUnit\Framework\TestCase;2require_once 'RegularExpression.php';3{4 public function testRegularExpression()5 {6 $this->assertEquals('abc', RegularExpression::getFirstMatch('abcde', '/abc/'));7 }8}9{10 public static function getFirstMatch($string, $pattern)11 {12 preg_match($pattern, $string, $matches);13 return $matches[0];14 }15}16use PHPUnit\Framework\TestCase;17require_once 'RegularExpression.php';18{19 public function testRegularExpression()20 {21 $this->assertEquals('abc', RegularExpression::getFirstMatch('abcde', '/abc/'));22 }23}24{25 public static function getFirstMatch($string, $pattern)26 {27 preg_match($pattern, $string, $matches);28 return $matches[0];29 }30}31require_once 'PHPUnit/Framework/TestCase.php';32require_once 'RegularExpression.php';33{34 public function testRegularExpression()35 {36 $this->assertEquals('abc', RegularExpression::getFirstMatch('abcde', '/abc/'));37 }38}39{40 public static function getFirstMatch($string, $pattern)41 {42 preg_match($pattern, $string, $matches);43 return $matches[0];44 }45}46require_once 'PHPUnit/Framework/TestCase.php';47require_once 'RegularExpression.php';48{49 public function testRegularExpression()50 {51 $this->assertEquals('abc', RegularExpression::getFirstMatch('abcde', '/abc/'));52 }53}54{55 public static function getFirstMatch($string, $pattern)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!