您将如何处理字符串通配符,而不只是比较正确的值?
我注意到 C++ 没有标准形式的正则表达式。尽管检查匹配值的方法有很多,但是当您需要复杂的公式来将一个值与另一个值进行比较,而无需数十行嵌套 IF 子句或极长的 OR 语句时,会发生什么情况?
简而言之,您将如何处理与 C++ 的正则表达式样式比较?
编辑:没有外部库,我有点新手。
It has come to my attention that there is no standard form of regular expressions for C++. Although there are many ways for you to check for matching values, what happens when you need complicated formula to compare one value to another, without dozens of lines just for nested IF clauses, or extremely long OR statements?
In short, how would you approach regular expressions style comparisons with C++?
EDIT: Without external libraries, I'm a bit of a newbie.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需看看 Boost.Regex,或者在某些现代编译器和库中,std::tr1::regex< /a>.
您可能还需要考虑使用 Perl 兼容正则表达式 库 PCRE。
编辑:您对问题的澄清要求不使用任何外部库,最终会增加您要做的工作量。这是 Rob Pike 的正则表达式匹配代码,这可能是您努力的良好开端。
You need look no further than Boost.Regex, or in some modern compilers and libraries, std::tr1::regex.
You may also want to consider using Perl-Compatible Regular Expressions library, PCRE.
EDIT: your clarification of the question to require not using any external libraries, ultimately increases the amount of work you'll be doing. Here is Rob Pike's regex matching code, which may be a good start for your efforts.
简而言之, Boost.Regex 或std::tr1::regex。
In short, Boost.Regex or std::tr1::regex.
查看 http://www.pcre.org/。
Check out http://www.pcre.org/.