Regular Expression Module

BlitzMax Forums/BlitzMax Programming/Regular Expression Module

Brucey(Posted 2007) [#1]
I've added a cross-platform Regular Expression module to my website (see link in sig).

It doesn't have any external requirements as it comes with the open-source PCRE library.

As usual, it has some examples and is fully documented.. and it's free...

:o)


Koriolis(Posted 2007) [#2]
Excellent. I'll certainly have a good use of this module. Thanks to share.


seyhajin(Posted 2007) [#3]
Nice, good job Brucey !


Yan(Posted 2007) [#4]
Bah...Something *else* to look up. ;o)

Cheers Mr Brucey. :o)


Azathoth(Posted 2007) [#5]
There are some errors in test_06.bmx, I fixed it by passing "!FLOAT!" to regex.ReplaceAll instead of TRegEx.Create as how it was originally.


Brucey(Posted 2007) [#6]
Thanks Azathoth, have fixed the other tests too...

:-)


grable(Posted 2007) [#7]
Great module brucey!

One thing i miss though, is access to submatches within a replace.

Heres a simple adition to TRegex.Replace for it =)
	' if there wasn't an error... process the match (even for no-match)
	While result >= 0 Or result = REGEX_NOMATCH		
'----->>
		Local replaceStr:String = replaceWith
		Local ofs:Int Ptr = Int Ptr(offsets)
		For Local i:Int = 0 To result
			Local idx:Int = i * 2
			replaceStr = replaceStr.Replace( "\" + i, lastTarget[ofs[idx]..ofs[idx+1]])
		Next
'-----<<
		If result > 0 Then
			' add text so far, and the replacement
			retString:+ lastTarget[startPos..Int Ptr(offsets)[0]] + replaceStr '<---



SpaceAce(Posted 2007) [#8]
WooHOO! I love, love, love regular expressions. I am so glad you did this so I don't have to. It seems my "put it off just a little while longer" strategy has paid off yet again.

SpaceAce


jsp(Posted 2007) [#9]
Can't open the zip, looks somehow broken??

EDIT: OK, works now. Thanks


xlsior(Posted 2007) [#10]
Oooooooh. Nice one!


Brucey(Posted 2007) [#11]
Have added Mr grable's code-tweak to the module (1.02). Thanks grable :-)

Didn't realize you'd already made a "posix" regex module for win32... guess I need to look harder before I dive into new things.