fork download
  1. <?php
  2. $str="typedef enum AG_TMP_MSG_ID
  3. {
  4. //single line comment
  5. /*multi-line
  6. comment*/
  7. TMP_ERR_SUCCESS = 0x00, //comment
  8. TMP_ERR_FAILURE = 0x01, //comment
  9. TMP_ERR_SETUP,// do not use TMP_ERR_SETTING
  10. TMP_MSG_NAME,/*TMP_PRODUCT*/
  11. TMP_MSG_NAME_1/*TMP_PRODUCT_1*/,
  12. TMP_MSG_NAME_BASE_MAX = TMP_ASD_OPTYPE_NAME_BASE + TMP_ASD_TRX_TYPE_END,
  13. }";
  14. preg_match_all('/(?>\/{2}.*?\n|\/\*.*?\*\/|=.*?,|^.*?\{)(*SKIP)(*F)|TMP_\w*/s',
  15. $str,
  16. $matches);
  17. var_dump($matches);
  18. ?>
  19.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
array(1) {
  [0]=>
  array(6) {
    [0]=>
    string(15) "TMP_ERR_SUCCESS"
    [1]=>
    string(15) "TMP_ERR_FAILURE"
    [2]=>
    string(13) "TMP_ERR_SETUP"
    [3]=>
    string(12) "TMP_MSG_NAME"
    [4]=>
    string(14) "TMP_MSG_NAME_1"
    [5]=>
    string(21) "TMP_MSG_NAME_BASE_MAX"
  }
}