Posted: Thu Jan 29, 2004 3:01 pm
wow! Brilliant - I bet there's only a Lib for Windows, though, Linux would be very nice. (I cant check reelmedia because the reelmedia server is refusing connections again)
http://www.purebasic.com
https://www.purebasic.fr/english/
I know, but does naw?Kale wrote: Thats exactly what i was pointing at earlier on in this thread.
Yes it is a Windows Lib. I couldn't compile it for linux, because i've no linux system running atm...naw wrote:wow! Brilliant - I bet there's only a Lib for Windows, though, Linux would be very nice.
Try: http://www.florian-s.com/download/PureBasic/naw wrote:(I cant check reelmedia because the reelmedia server is refusing connections again)
There's pcre (perl compatible regular expressions) which is GPL and has been ported as both static and dynamic libraries for many platforms. If you can understand the API (and there's not much to it, maybe 6 or 8 functions you need to use) then you should be able to use them in PureBasic using either the Library library or using the DLL importer.naw wrote:wow! Brilliant - I bet there's only a Lib for Windows, though, Linux would be very nice. (I cant check reelmedia because the reelmedia server is refusing connections again)
Code: Select all
; RegCompEx Test
*compiled.REGEXP
Debug RegCompEx(@*compiled, "(<TITLE>|<title>)(.*)(</TITLE>|</title>)")
; RegErrorEx Test
error$ = Space(80)
PeekS(RegErrorEx(#REGEXP_ESPACE, *compiled, error$, 80))
Debug error$
; RegNSubExpEx Test
Debug "Number of SubExpressions: " + Str(RegNSubExpEx(*compiled))
; RegExecEx Test
Test$ = "<HTML><HEAD><TITLE>PureBasic : visual basic compiler, easy & optimized basic programming language, basic, compiler</TITLE></HEAD><BODY></BODY></HTML>"
Dim test.REGMATCH(RegNSubExpEx(*compiled))
Debug RegExecEx(*compiled, Test$, RegNSubExpEx(*compiled), @test(0))
Debug PeekS(@Test$ + test(0)\subexp_begin) ; Test REGMATCH offset
Debug PeekS(@Test$ + test(1)\subexp_begin)
Debug PeekS(@Test$ + test(2)\subexp_begin)
Debug PeekS(@Test$ + test(3)\subexp_begin)
Debug PeekS(@Test$ + test(4)\subexp_begin)
; RegSubEx Test
*buffer = AllocateMemory(1, 200, 0)
Debug RegSubEx(*compiled, Test$, "\2", @*buffer)
Debug "The Buffer contains: " + PeekS(*buffer)
; RegFreeEx Test
RegFreeEx(*compiled)
Code: Select all
abc\. "." is a special character in RE meaning repetitions of the previous character - so "A." will match "AA" but not "AB". The "\" escapes the special meaning of the next character which is "." so effectively "abc\." matches "abc."
abc\\ "\" = escape, so "abc\\" matches "abc\"
abc.+ - sorry dont know what "+" means - never used it...
abc.* will match "abccccc" or abcccdd234234" but not "abdefg"
abc.[ is a badly formed RE - ie "abc.[e-z]" would match "abccd" or "abccccce" or "abccccccccx"
if you wanted to match "abc.[" you would have to use "abc\.\["
Code: Select all
; concept
;
; take pattern apart, split it up in blocks
; per block: type (0 exact match to a number of chars, 1 fancy stuff)
; per block: min (0 or 1) and max (1 or n) characters
; put this stuff in a table
; and now the real stuff... l = len(string)
; startpos(1) = 1, endpos(1) = l
; n = 1
;
; again = false
; repeat
; try to match block(n) *as far away as possible* aka. up to endpos(n)
; if match
; p = found pos (last character of match, in range startpos(n) to endpos(n))
; endpos(n) = p
; inc n
; if n< nr of blocks
; startpos(n) = p+1
; endpos(n) = l
; again = true
; endif
; else
; no match, damn
; dec n
; if n>1
; endpos(n) = endpos(n)-1
; again = true
; endif
; endif
; until again = false
;
; if n < 1 no match
; if n > nr of blocks and endpos(nr of blocks) = l then there is a match
so, what is it now?. Matches any single character except newline. In awk, dot can match newline also.
[/endquote]
abc\. "." is a special character in RE meaning repetitions of the previous character - so "A." will match "AA" but not "AB". The "\" escapes the special meaning of the next character which is "." so effectively "abc\." matches "abc."
that's correct. many unix programs deal with regexps, like grep, sed, awk, vi, some shells.. every one has special metacharcters and some are differently implemented. so its up to you to decide which implementation you will follow.."." Matches any single character except newline. In awk, dot can match newline also.
yes it is. it matches any expression, because the last asterisk (*) means: the expression [ABC|CDE|X*] has to appear "0" or "n" times.is this valid? [ABC|CDE|X*]*
sure this is valid, too. this is a very simple expressions: matching "abc" or any lowercase character "a", "b", "c",...,"z"the following i haven't seen so i assume it isn't valid, or is it?
(abc|[a-z])