BREXEXP.DLLをダウンロードする。
http://www.hi-ho.ne.jp/babaq/bregexp.html

BMatchのみつかってみる。VC用は使えるがVB用の関数はエラーになる。
ポインタ操作が絡むのでややこしい。
構造体の定義は適当なのできちんと動くか不明。

#console

Type BREGEXP
outp As BytePtr
outendp As BytePtr
splitctr As Integer
splitp As BytePtr
rsv1 As Integer
parap As BytePtr
paraendp As BytePtr
transtblp As BytePtr
startp As BytePtr
endp As BytePtr
nparens As Integer
end type

Declare Function BMatch Lib "bregexp" (str As BytePtr, target As BytePtr, targetendp As BytePtr,ByRef rxp As bregexp, msg As BytePtr) As Long

Dim rexp(31) As Byte
Dim buf(31) As Byte
Dim err(31) As Byte
Dim rtn As Long
Dim struct_brp As BREGEXP

lstrcpy(buf,"abc ABC") '対象となる文字列
lstrcpy(rexp,"/abs/") '正規表現

rtn=BMatch(rexp,buf,buf+7,struct_brp,err) '文字列の長さはポインタに文字数を加算した値になる(buf+7)

if rtn=0 then
print "noマッチです"
else if rtn=-1 then
print "?"
else
print "マッチしました"
endif

print MakeStr(rexp)
print MakeStr(buf)
print "errmsg>";MakeStr(err)

タグ:

+ タグ編集
  • タグ:
最終更新:2010年12月05日 00:56