PCRE (Perl Compatible Regular Expressions) is a regular expression function library written in C language and compiled by Philip Hazel. PCRE is a lightweight function library, which is much smaller than the regular expression library in boost. PCRE is very easy to use and has powerful functions. Its performance exceeds the POSIX Regular Expression Library and some classic Regular Expression Libraries. In Linux, many software rely on PCRE for regular expression judgment.
-----------------------------------------------------------
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
-----------------------------------------------------------
Well, we can use the pcre81s. Lib library compiled by biterider (which can be easily compiled by myself). Thanks, haha.
Let me give you a small example. For more information, see the PCRE official website. Google's first one is.
; **************************************** ********************
; * -- = -- * 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;/* shocould 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
RET
. Endif
Invoke pcre_exec, eax, 0, offset szsrc, sizeof szsrc, 0, offset ovector, oveccount
; The number of matches returned for successful matches. If no matches are returned,-1 is returned.
MoV RC, eax
MoV edX, eax
And EDX, 80000000 H
. If edX! = 0
Invoke crt_printf, offset fmt3, eax
Invoke MessageBox, null, 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