Hi All,
In DataStage, is there any way to remove all the characters from a String except digits 0 to 9.
Thanks In Advance,
Tom.
Is there a way to remove characters from String except 0-9
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 41
- Joined: Fri Jun 04, 2004 5:52 am
- Location: Bangalore
Only way I've been able to do it was to write a routine that check each character and if it's not A - Z or 0 - 9 then it would skip it and continue to the next.
If it is one of the wanted characters, it would concat it to a new string and at the end of the routine pass back this "cleaned up" string to you.
Obviously running this through a lot of data does impact your performance quite heavily.
If it is one of the wanted characters, it would concat it to a new string and at the end of the routine pass back this "cleaned up" string to you.
Obviously running this through a lot of data does impact your performance quite heavily.
Re: Is there a way to remove characters from String except 0
Use Result = Oconv("InputString","MCN")
tombastian wrote:Hi All,
In DataStage, is there any way to remove all the characters from a String except digits 0 to 9.
Thanks In Advance,
Tom.
Naren's post is correct, just remember to remove the quotes around the first parameter
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Or something a little less obtuse:
Does the exact same Oconv under the covers but at least you have an idea what is going on. Check out the other Transforms that come with the product, there's some handy stuff in there.
Next time you need to do something like this and aren't sure if there is something built in or not, I've found something I think is pretty handy. Bring up the Online Help in the Designer and switch to the Index tab. Type BASIC and then arrow down to 'alphabetic list of' and hit enter. This is a nice page in-and-of itself, but wait - there's more!
You'll see a note at the top of the page saying something on the order of 'if you are unsure of what you need, see BASIC Tasks. You can also get there right from the Index. Lots of good functions listed by task type. Wouldn't have (directly) solved your digits problem, but a good resource.
You should also check out all of the various Conversion Codes available for the Iconv/Oconv functions. It's amazing how many things other than dates that you can 'conv' with them.
Code: Select all
DIGITS(YourField)
Next time you need to do something like this and aren't sure if there is something built in or not, I've found something I think is pretty handy. Bring up the Online Help in the Designer and switch to the Index tab. Type BASIC and then arrow down to 'alphabetic list of' and hit enter. This is a nice page in-and-of itself, but wait - there's more!
You'll see a note at the top of the page saying something on the order of 'if you are unsure of what you need, see BASIC Tasks. You can also get there right from the Index. Lots of good functions listed by task type. Wouldn't have (directly) solved your digits problem, but a good resource.
You should also check out all of the various Conversion Codes available for the Iconv/Oconv functions. It's amazing how many things other than dates that you can 'conv' with them.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers