2022年8月1日 星期一

用 Regexp 篩選註解

多行程程式註解:/* */

/\*(.|[\r\n])*?\*/

單行程程式註解://

/{2,}.*

XML註解:<!-- -->

<!--(.|\n)*?-->

Lua 多行註解:--[[ --]]

--\[{2,}(.|\r|\n)*?--\]{2}

MySQL、bash 的單行註解:#

#.*

Python 多行註解:""" """

"{3}(.|[\r\n])*?"{3}

參考資料

Ostermiller, S. (2013, October 7). regex - Regular expression to remove comment. Stack Overflow. https://stackoverflow.com/a/17579177
code_bash, (2018, February 5). regex - Regular expression to remove comment. Stack Overflow. https://stackoverflow.com/a/49070539

沒有留言:

張貼留言