fork download
  1. <?php
  2. function convert($keyword) {
  3. $wResult = preg_replace('/([[:lower:][:digit:]])?([[:upper:]]+)/u','$1 $2', $keyword);
  4. return $wResult;
  5. }
  6.  
  7. $search_keyword = array(
  8. "comeHEREtomorrow",
  9. "KissYouTODAY",
  10. "comeÜndeHere",
  11. "NEVERSAYIT",
  12. "2013willCome",
  13. "Before2013ends",
  14. "IKnowThat",
  15. "#whatiknow"
  16. );
  17. $need_keyword = array(
  18. "come HERE tomorrow",
  19. "Kiss You TODAY",
  20. "come Ünde Here",
  21. "NEVERSAYIT",
  22. "2013 will Come",
  23. "Before 2013 ends",
  24. "I Know That",
  25. "# whatiknow"
  26. );
  27.  
  28. foreach ($search_keyword as $key => $w) {
  29. $wExpected = $need_keyword[$key];
  30.  
  31. $wResult = convert($w);
  32.  
  33. $check = strcmp($wExpected, $wResult);
  34. $checkWord = ( $check == 0 ? "SUCCESS" : "FAILURE" );
  35.  
  36. echo "try $key,\t keyword: \"$w\" expected: \"$wExpected\" result: \"$wResult\" check: $check ($checkWord),\n";
  37. }
  38. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
try 0,	 keyword: "comeHEREtomorrow" expected: "come HERE tomorrow" result: "come HEREtomorrow" check: -1 (FAILURE),
try 1,	 keyword: "KissYouTODAY" expected: "Kiss You TODAY" result: " Kiss You TODAY" check: 1 (FAILURE),
try 2,	 keyword: "comeÜndeHere" expected: "come Ünde Here" result: "comeÜnde Here" check: -1 (FAILURE),
try 3,	 keyword: "NEVERSAYIT" expected: "NEVERSAYIT" result: " NEVERSAYIT" check: 1 (FAILURE),
try 4,	 keyword: "2013willCome" expected: "2013 will Come" result: "2013will Come" check: -1 (FAILURE),
try 5,	 keyword: "Before2013ends" expected: "Before 2013 ends" result: " Before2013ends" check: 1 (FAILURE),
try 6,	 keyword: "IKnowThat" expected: "I Know That" result: " IKnow That" check: 1 (FAILURE),
try 7,	 keyword: "#whatiknow" expected: "# whatiknow" result: "#whatiknow" check: -1 (FAILURE),