【发布时间】:2017-01-05 03:19:42
【问题描述】:
notepad++ 的函数列表插件工作正常,除了我的函数名称以“for / while / if”开头。
例如,我在表单类中有函数。所以他们以“表单”开头(例如 form_information)。 所以函数名不会出现在函数列表中,因为函数名以'for'开头。
有人有同样的问题,或者可能是正则表达式中的解决方案?
这是PHP函数列表的正则表达式和xml。
<parser id="php_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*([\s]*|[\s]*(extends|implements|(extends[\s]+(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+[\s]+implements))[\s]+(\,[\s]*|(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))+[\s]*)?\{"
openSymbole = "\{"
closeSymbole = "\}"
displayMode="node">
<className>
<nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
<nameExpr expr="[\s]+[\w]+\Z"/>
<nameExpr expr="[\w]+\Z"/>
</className>
<function
mainExpr="^[\s]*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+[\s]+)?(function[\s]+)+([\w]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\{]*\{">
<functionName>
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
<!-- comment below node if want display method with parmas -->
<funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
</functionName>
</function>
</classRange>
<function
mainExpr="^[\s]*function[\s]+\w+\("
displayMode="$className->$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_]+"/>
</functionName>
<className>
<nameExpr expr="[\w_]+(?=[\s]*::)"/>
</className>
</function>
感谢您的宝贵时间!
【问题讨论】:
-
将
(?!(if|while|for|switch))更改为(?!(if|while|for|switch)\b)和(?!(if|while|for))yo(?!(if|while|for)\b).. 这可能对您有所帮助。 -
谢谢!这对我也有用:)
标签: php regex function plugins notepad++