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:
- http://www.itjungle.com/fhg/fhg030409-story01.html
- http://www.itjungle.com/fhg/fhg022509-story01.html
These should help.
Mike Wills
2009-04-30 16:32:28
+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
2009-05-12 19:41:12