C++:我应该使用什么正则表达式库? [英] C++: what regex library should I use?
问题描述
我正在开发一个在基于 linux 的系统上运行的商业(非开源)C++ 项目.我需要在 C++ 代码中做一些正则表达式.(我知道:我现在有两个问题.)
I'm working on a commercial (not open source) C++ project that runs on a linux-based system. I need to do some regex within the C++ code. (I know: I now have 2 problems.)
问题:经常使用 C/C++ 进行正则表达式的人推荐我研究哪些库?快速搜索引起了我的注意:
QUESTION: What libraries do people who regularly do regex from C/C++ recommend I look into? A quick search has brought the following to my attention:
1) Boost.Regex(我需要阅读 Boost 软件许可证,但这个问题与软件许可证无关)
1) Boost.Regex (I need to go read the Boost Software License, but this question is not about software licenses)
2) C(非 C++)POSIX 正则表达式(#include
2) C (not C++) POSIX regex (#include <regex.h>, regcomp, regexec, etc.)
3) http://freshmeat.net/projects/cpp_regex/(我对这个;似乎是 GPL,因此不能在这个项目中使用)
3) http://freshmeat.net/projects/cpp_regex/ (I know nothing about this one; seems to be GPL, therefore not usable on this project)
推荐答案
感谢所有建议.
我今天尝试了一些东西,对于我们正在尝试做的事情,我选择了最简单的解决方案,我不必下载任何其他 3rd 方库.最后,我 #include
I tried out a few things today, and with the stuff we're trying to do, I opted for the simplest solution where I don't have to download any other 3rd-party library. In the end, I #include <regex.h> and used the standard C POSIX calls regcomp() and regexec(). Not C++, but in a pinch this proved to be the easiest.
这篇关于C++:我应该使用什么正则表达式库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!