AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
substi (String subinfo, Regexp re, String target) yoix.re
substi (String subinfo, String re_pattern, String target)  
substi (String subinfo, Subexp subexp)  
 
Replaces the first portion of the target string that is matched by the regular expression re according to the substitution information provided by subinfo. In the simplest case, the first match made by re in the target will be directly replaced by the contents of subinfo. However, if the regular expression contains grouping information (i.e., sub-expressions enclosed by parentheses), then the portion of target matched by a sub-expression can be referenced in subinfo by means of a backslash-number sequence (i.e., \n, where n is the number of the sub-expression, counting in order from left to right within the regular expression, that made the match). Moreover, either n equal to 0 or an ampersand (&) refers to the entire match made by the regular expression. If no substitutions are made target itself is returned, otherwise a new string containing the substitutions is returned. Consequently, it is possible to test for the occurrence of substitutions by using simple equality to test the string value returned by the substi call against the original target string value.

When a String representation of a regular expression, re_pattern, is provided as the second argument, it is treated as the equivalent of providing either new Regexp { String pattern = re_pattern; } or regexp(re_pattern). If a Subexp object, subexp, is the second argument, then the target string and matched range information contained within it are used in making the substitution.
 
 Example:   For usage examples, refer to the documentation for Subexp.
 
 Return:   String
 
 See Also:   gsubsti, gvsubsti, regexec, Regexp, regexp, regsub, Subexp, vsubsti

 

Yoix is a registered trademark of AT&T Intellectual Property.