fork download
  1. <?php
  2.  
  3. $str = "
  4. //이 파일 수정 시에 절대 EditPlus를 사용하시지 마십시요.
  5. //유니코드 부분에 충돌이 있습니다.
  6. //메모장을 사용하여 주십시오.
  7. // textServer.inc : Multi language text
  8. // textClient.inc : Multi language text
  9. // 이야기식 변수 표현 : %s
  10. // 수치 변수 표현 : %d
  11.  
  12.  
  13.  
  14. TID_BLANK 0xffffffff
  15. {
  16. IDS_TEXTCLIENT_INC_000000
  17. }
  18.  
  19. TID_APP_NAVIGATOR 0xffffffff
  20. {
  21. IDS_TEXTCLIENT_INC_000001
  22. }
  23. ";
  24.  
  25. $re = '/(^\w+)\s+(0x[a-f\d]+)\s+\{\s+(\w+)/m';
  26. preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
  27. $res = array_map(function ($match) { return array_slice($match, 1); }, $matches);
  28. print_r($res);
Success #stdin #stdout 0.02s 82944KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => TID_BLANK
            [1] => 0xffffffff
            [2] => IDS_TEXTCLIENT_INC_000000
        )

    [1] => Array
        (
            [0] => TID_APP_NAVIGATOR
            [1] => 0xffffffff
            [2] => IDS_TEXTCLIENT_INC_000001
        )

)