我在awk文件中使用了以下正则表达式
beg_ere = "^[[:space:]]*([#;!/]{2}|@c)[[:space:]]+(HD) [[](OPCON)[]] .*[[:space:]]*$"有了它,我就能匹配以下几行
## HD [OPCON] this,that
## HD [OPCON] this,that,other但不是
## HD [OPCON]如何更改beg_ere以便与## HD [OPCON]匹配?
this,that,other是由逗号分隔的一系列关键字。行中可以有任意数量的关键字,包括零。
发布于 2023-02-25 15:05:28
试一试
beg_ere = "^[[:space:]]*([#;!/]{2}|@c)[[:space:]]+(HD) [[](OPCON)[]].*$"注意:在.*之前删除单个空格;在此之后也删除冗余的[[:space:]]*。
https://unix.stackexchange.com/questions/736887
复制相似问题