tags:

views:

930

answers:

2

In RPG IV how can I take a string and eliminate all instances of a character in specific or replace them with another one ?. This is kind of like string replace built in methods in other programmnig languages. Ex: take 021-123450-23-4 and covert to 021123450234

+1  A: 

Take a look at the following articles:

These should help.

Mike Wills
+2  A: 

To remove all hyphens:

new_string = %XLATE( string, '-', '' );

To replace all hyphens with ampersand:

new_string = %XLATE( string, '-', '&' );

If you want to replace more than a single character then you're going to have to roll your own function/code as described in the articles Mike Wills pointed to.

Paul Morgan