使用正则表达式匹配JS函数代码

时间:2022-07-04 19:02:20

使用正则表达式匹配JS函数代码

String someFunction="init";

Pattern regex = Pattern.compile("function\\s*?"+someFunction+"\\(.*?\\)\\s*?\\{[^{}]*?(\\{.*?\\})*[^{}]*?\\}", Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE);

相关文章