Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Using the rexexp_substr function in TD14 - response (2) by vt186001

$
0
0

Hi Joe,
There was a discrepancy between the documentation and the actual code.  The fix is in the work.  In the meantime, regexp_replace can be used to simulate this by specifying the starting position and ending position in the pattern with the characters '^' and '$' respectively so that the entire matching string will be replaced by the desired group/sub expression.  Note that the group/sub expression must be preceded by a backlash.
Example:

regexp_replace( thesql -- source_string
                     ,'^SELECT\s+([\w]+)\.?([\w]+)(?:[\s])(?:AS)?\s+(\w+)\s+FROM\s+(\w+)\.(\w+)\s+(?:AS)?\s+\1$' --pattern

                     ,'\1'   --the desired group to be returned
                     ,1   -- position_arg
                     ,1   -- occurrence_arg
                     ,'i' -- match_arg (Ignore case)
                     ) as Theresult;
 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>