diff options
Diffstat (limited to 'ipl/procs/reassign.icn')
-rw-r--r-- | ipl/procs/reassign.icn | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ipl/procs/reassign.icn b/ipl/procs/reassign.icn new file mode 100644 index 0000000..f47587d --- /dev/null +++ b/ipl/procs/reassign.icn @@ -0,0 +1,57 @@ +############################################################################# +# +# 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 |