作者a2975313 (GN)
看板RegExp
标题Re: [问题] 过滤函式呼叫格式
时间Sat Apr 29 16:30:20 2017
我目前是用 (?!\b(if|while|for|switch|function)\b)\b\w+(?=\s*\()\([^\)]*\)
可以避掉if for switch 的pattern
剩下避掉函式定义的pattern
因为function tempA(){}也符合identifier()的格式
※ 引述《a2975313 (GN)》之铭言:
: 标题: [问题] 过滤函式呼叫格式
: 时间: Mon Apr 24 10:48:10 2017
:
:
: 大家好, 我使用c#想从javascript程式码中过滤出里面有哪些"函式呼叫"
:
: 过滤格式是identifier(...)
:
: 我目前是用→ .*\w+\(.*\).*
:
: 但过滤出的结果会包含if()、for()、switch()...
:
: 请问正规式要如何避掉这些非函式呼叫的东西, 谢谢.
:
: --
:
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.27.46.123
: ※ 文章网址: https://webptt.com/cn.aspx?n=bbs/RegExp/M.1493002092.A.CDE.html
: 推 mars90226: 简单的做法是 \b(?!if|for)\w+\(.*\) 04/24 20:19
: → mars90226: 加入 negative lookahead 把关键字挡掉 04/24 20:19
: → mars90226: 不过你这个方式遇上 a(b()) 就找不出来 b 了吧? 04/24 20:20
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 218.164.23.192
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/RegExp/M.1493454623.A.188.html
1F:→ a2975313: 请问使用lookahead如何加入whitespace的判断 05/02 20:17