PCRE(Perl Compatible Regular Expressions中文含义:perl语言兼容正则表达式)是一个用C语言编写的正则表达式函数库,由菲利普.海泽(Philip Hazel)编写。PCRE是一个轻量级的函数库,比Boost之中的正则表达式库小得多。PCRE十分易用,同时功能也很强大,性能超过了POSIX正则表达式库和一些经典的正则表达式库。linux 下很多款软件都依赖 PCRE 来做正则表达式判断。
-----------------------------------------------------------
Hi
For a project I’m working on I needed the PCRE library. I looked on the official site and quickly found out that there is no updated static library around to download. After spending some hours with VS9 I noticed that VS6 was a much better choice because of header dependencies. Finally I got a compiled static library that works fine with masm.
Biterider 2010-10-15 14:50:59
-----------------------------------------------------------
嗯,就用Biterider编译好的pcre81s.lib库(自己也很容易编译哦^_^),感谢,呵呵。
我就给一个小的例子吧,更多的说明请参看pcre的官网,google第一个就是的。
;************************************************************
;*--==--* Simple asm program to call pcre lib.
;*--==--* By G-Spider 2010.11.28
;*--==--* Web:http://blog.csdn.net/G_Spider
;*--==--* ---------------------------------------------------
;*--==--* ml /c /coff asmpcre.asm
;*--==--* link /subsystem:console asmpcre.obj
;************************************************************
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include msvcrt.inc
include PCRE81S.inc ;<-------
includelib user32.lib
includelib kernel32.lib
includelib msvcrt.lib
includelib PCRE81S.lib ;<-------
OVECCOUNT equ 30 ;/* should be a multiple of 3 */
EBUFLEN equ 128
BUFLEN equ 1024
;***********************************************************;
.data
szSrc db ' href=http://blog.csdn.net/G_Spider+c%2B%2B+',0
szPattern db 'http://(.*)(..Spider)',0
szovector db 'szovector[]= ',0dh,0ah,0
fmt1 db 'String : %s',0dh,0ah,0
fmt2 db 'Pattern: %s',0dh,0ah,0dh,0ah,0
fmt3 db '%d ',0
fmt4 db 'Return pattern string:',0dh,0ah,0dh,0ah,0
fmt5 db '%s',0dh,0ah,0
szPause db 'Pause',0
.data?
_error dd ?
erroffset dd ?
ovector dd OVECCOUNT dup(?)
rc dd ?
result dd ?
;***********************************************************
.code
;-----------------------------------------------------------
start:
invoke crt_printf,offset fmt1,offset szSrc
invoke crt_printf,offset fmt2,offset szPattern
invoke pcre_compile,offset szPattern,0,offset _error,offset erroffset,0
.if eax==NULL
invoke MessageBox,NULL,0,0,0
ret
.endif
invoke pcre_exec,eax,0,offset szSrc,sizeof szSrc,0,0,offset ovector,OVECCOUNT
;匹配成功返回匹配数,没有匹配返回-1
mov rc,eax
mov edx,eax
and edx,80000000h
.if edx!=0
invoke crt_printf,offset fmt3,eax
invoke MessageBox,NULL,0,0,0
invoke ExitProcess,0
.endif
invoke crt_printf,offset fmt4
xor eax,eax ;eax=1?
.while eax<rc
push eax
invoke pcre_get_substring,offset szSrc,offset ovector,rc,eax,offset result
invoke crt_printf,offset fmt5,result
pop eax
inc eax
.endw
;int pcre_get_substring(const char *subject, int *ovector,
;int stringcount, int stringnumber,
;const char **stringptr)
invoke crt_printf,offset szovector
xor eax,eax
.while eax<OVECCOUNT
push eax
invoke crt_printf,offset fmt3,ovector[4*eax]
pop eax
inc eax
.endw
invoke pcre_free,rc
invoke crt_system,offset szPause
invoke ExitProcess,0
end start