RegEx Removing Methods from Code

后端 未结 2 1254
-上瘾入骨i
-上瘾入骨i 2021-01-06 08:49

With Regular Expressions I\'m trying to remove all the methods/functions from the following code. Leaving the \"global scope\" alone. However, I can\'t manage to make it mat

2条回答
  •  無奈伤痛
    2021-01-06 09:44

    I believe using PHP's built-in Tokenizer feature or Zend_CodeGenerator from Zend Framework is a more safe way. These will also keep your code more readble.

    This is just because if you want use regexp to parse source codes, you must maintain your own tokens set but there is a built-in solution.

提交回复
热议问题