JS正则匹配console,包括换行、空格、分号

2026-02-15 19:27:10

1、匹配console,无论是log、error、waring等

console\..*\(([\s\S]*?)\)(;?)

2、匹配console.log

console\.log\(([\s\S]*?)\)(;?)

3、匹配console.error

console\.error\(([\s\S]*?)\)(;?)

4、要匹配其它的很简单,如图示把图中的“.*”替换成任意的属性名

JS正则匹配console,包括换行、空格、分号

猜你喜欢