C++ 中的正则表达式

发布于 2024-10-19 04:05:03 字数 82 浏览 2 评论 0原文

我想为正则表达式编写 C++ 库。我知道有很多可用的库,但我想学习正则表达式背后的理论并自己实现它。

有人可以指导我应该从什么开始吗?

I want to write C++ library for Regular Expression. I know there are many libraries available but I want to learn theory behind regular expression and implemented it by myself.

Can anybody please guide on what should I start with.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

放肆 2024-10-26 04:05:03

http://swtch.com/~rsc/regexp/regexp1.html 有一个很好地解释了正则表达式的两种主要方法、它们的权衡,以及如何使更快的方法 (DFA) 在大多数实现无法使用它们的许多情况下可用。

http://swtch.com/~rsc/regexp/regexp1.html has a good explanation of the two major approaches to regular expressions, their trade-offs, and how to make the faster one (DFAs) usable in a lot of cases that most implementations fail to use them for.

焚却相思 2024-10-26 04:05:03

《编译器:原理、技术和工具》一书也值得一看,它深入介绍了正则表达式解析背后的技术(以及有关 DFA 和 NDFA 的理论)。它有很好的伪代码示例,可以帮助创建自己的实现

It's also worth looking into book "Compilers: Principles, Techniques, and Tools" that deeply covers techniques behind regular expression parsing (and the theory regarding DFAs and NDFAs). It has good pseudo-code examples that could help in creating own implementation

薄暮涼年 2024-10-26 04:05:03

只要您想编写该库,那么除了参考其他答案提供的优秀资源之外,您还可以探索实现 N3225

As long as you want to write the library, then in addition to referencing the excellent resources other answers give, you might explore implementing the C++0x specification for regular expressions found in chapter 28 of N3225.

灯角 2024-10-26 04:05:03

就我而言,这是一本关于正则表达式主题的书。它可能无法让您完全弄清楚如何编写 C++ 库,但对理论的解释非常出色,并且包含许多上下文中正则表达式实际应用的示例。

http://oreilly.com/catalog/9780596528126?green =9514625548&cmp=af-mybuy-9780596528126.IP

As far as I'm concerned, this is THE book on the subject of regular expressions. It may not get you all the way to figuring out how to code up a C++ library, but the explanation of the theory is excellent and it includes a lot of examples for the practical application of regular expressions in many contexts.

http://oreilly.com/catalog/9780596528126?green=9514625548&cmp=af-mybuy-9780596528126.IP

梦里°也失望 2024-10-26 04:05:03

在 Microsoft 实施的 TR1 中,这是下一个报告C++0x 标准,有 库可用。

TR1 适用于 Visual 2008,默认情况下适用于 Visual 2010。

当然,只有当您计划在 Windows 平台上编程时,这才有意义。

我不知道 g++ 的 tr1 实现中是否包含 库。我想是的,但我不知道。

In the Microsoft implementation of the TR1, which is the report for the next C++0x standard, there is the <regex> library available.

the TR1 is available for visual 2008, and by default in visual 2010.

But that's interesting only if you plan to program on the windows plateform, of course.

I don't know if g++ includes the <regex> library in its tr1 implementation. I guess yes, but I don't know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文