Regular Expression Module

BlitzMax Forums/BlitzMax Programming/Regular Expression Module

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)

Excellent. I'll certainly have a good use of this module. Thanks to share.

Nice, good job Brucey !

Bah...Something *else* to look up. ;o)

Cheers Mr Brucey. :o)

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.

Thanks Azathoth, have fixed the other tests too...

:-)

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 '<---


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

Can't open the zip, looks somehow broken??

EDIT: OK, works now. Thanks

Oooooooh. Nice one!

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.