开发者

Regular Expression in C++

开发者 https://www.devze.com 2023-02-13 10:42 出处:网络
I want to write C++ library for Regular Expression. I know there are many libraries available but I want to learn theory behind regular expressi开发者_如何学Pythonon and implemented it by myself.

I want to write C++ library for Regular Expression. I know there are many libraries available but I want to learn theory behind regular expressi开发者_如何学Pythonon and implemented it by myself.

Can anybody please guide on what should I start with.


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.


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


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.


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


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.


I have used book http://www.amazon.com/Compiler-Design-C-Prentice-Hall-software/dp/0131550454 and implemented here http://code.google.com/p/regex/

0

精彩评论

暂无评论...
验证码 换一张
取 消