简体   繁体   English

std :: regex的正则表达式选项

[英]Regex options for std::regex

I was looking for a way of switching between multiline/singleline regex so that the $ means the end of input/the end of line. 我一直在寻找一种在多行/单行正则表达式之间切换的方式,以便$表示输入的结尾/行的结尾。 I've looked through different guides and they point to some OPTIONS for this. 我浏览了不同的指南,他们为此指出了一些选择。 However, I can't find any such options for std::basic_regex in http://www.cplusplus.com/reference/regex/basic_regex/basic_regex/ . 但是,在http://www.cplusplus.com/reference/regex/basic_regex/basic_regex/中找不到std :: basic_regex的任何此类选项。 I've came across a recommendation to use (s) (or something like) in the beginnning of a regex but it causes an exception. 我遇到了一个建议,在正则表达式的开头使用(s)(或类似的东西),但这会导致异常。

Are there a list of any additional options which can be passed to a std::regex in addition to flags that can be passed to basic_regex constructor? 除了可以传递给basic_regex构造函数的标志之外,是否还有其他可以传递给std :: regex的选项的列表?

Your (?s) flag is not yet supported by C++. C ++尚不支持您的(?s)标志。

But you can still do a multiline regex match. 但是您仍然可以进行多行正则表达式匹配。

To match everything on a single line use: .* 要在一行上匹配所有内容,请使用: .*

To match everything on multiple lines use: (?:.|\\n)* 要匹配多行中的所有内容,请使用: (?:.|\\n)*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM