Regular Expression Module

BlitzMax Forums/BlitzMax Programming/Regular Expression Module

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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