正则表达式以任何一个开头查找评论; 或#个字符

cap*_*hud 1 regex

我有ini文件,但在一个ini文件中有注释开头

; Enable the PHP scripting language engine under Apache.
engine = On
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
Run Code Online (Sandbox Code Playgroud)

和另一个

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=255
Run Code Online (Sandbox Code Playgroud)

目前找到第一个使用正则表达式的开头涉及使用

^(;).*$\n
Run Code Online (Sandbox Code Playgroud)

我尝试使用修改它

^[;#].*$\n 
Run Code Online (Sandbox Code Playgroud)

找到两个评论中的任何一个,但它找不到任何一种类型的评论正确的正则表达式?

你的所有建议都非常有帮助.我需要做的另一件事是关闭应用程序,然后重新打开它以查看更改是否生效.

enn*_*ler 9

这应该工作,但您可以尝试更改语法:

^(;|#).*$
Run Code Online (Sandbox Code Playgroud)