最近開始看《精通Regex(第3版)》,裡面提到了C/C++也有自己的Regex,但是該書介紹了Perl、Java、.NET、PHP……等語言的Regex的用法,唯獨沒有講述C/C++語言中的Regex,於是去網上搜尋了下,找到一個開源的C/C++Regex庫——Boost。
參照文章: VC6.0下配置Boost庫使用Regex
進行一些配置,也寫了測試案例,通過編譯。
可能會遇到的問題:
1、
Regex_test.cpp
d:"boostl"boost"regex"v4"perl_matcher_common.hpp(767) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Command line warning D4028 : minimal rebuild failure, reverting to normal build
Error executing cl.exe.
Regex_test.exe - 1 error(s), 1 warning(s)
是因為你修改了程式,直接按“Ctrl+ F5”運行程式,
修正方法:重新Rebuild下就OK了
2、
Compiling...
Regex_test.cpp
Linking...
LINK : fatal error LNK1104: cannot open file "libboost_regex-vc6-sgd-1_34_1.lib"
Error executing link.exe.
Regex_test.exe - 1 error(s), 0 warning(s)
可能是是標頭檔的緣故
libboost_regex-vc6-sgd-1_34.lib中“libboost_regex-vc6-sgd-1_34”的後面加“_1”即可
其他的方法的庫也應該也有這方面的問題。
由文章中講述的配置過程,可以適用於VC++ 7.1(Visual Studio .NET 2003)以及VC++ 8.0(Visual Studio 2005)。
by 夢書