############################################################################# # # File: reassign.icn # # Subject: Procedures to access RE groupings and format into a string # # Author: David A. Gamey # # Date: May 2, 2001 # ############################################################################# # # This file is in the public domain. # ############################################################################# # # Descriptions: # # ReAssign( s ) : s2 # # Replaces sequences of \n in s with the corresponding parenthesis # groups from the last regular expression match/find (if one exists). # # Special characters: # \n use nth parenthesis group # \\ escaped \ # \n.i nth group followed by a number # # ############################################################################# # # Links: regexp # ############################################################################ link regexp procedure ReAssign( s ) local s1, n s1 := "" s ? { while s1 := 1( tab(upto('\\')), move(1) ) do { if s1 ||:= ="\\" then next if n := integer(tab(many(&digits))) then { n := Re_ParenGroups[n] s1 ||:= n if ( =".", tab(any(&digits)) ) then move(-1) } } return s1 ||:= tab(0) } end