Removing a specific character from string
Moderators: chulett, rschirm, roy
Removing a specific character from string
Hello everybody
I have a string coming in
its like abc def hsk nmps etc
My requirement is to remove any letter 'a' from the words within the string if it appears as the last letter
For example
"abc def abca" should be come "abc def abc"
"abc def' will not change
"abc nko 2090a sksa" becomes "abc nko 2090 sks"
so on and so forth
As you noticed the string can be of varying length including words
I am trying by looping the string ( unsuccessfully ) and wanted to see
if anybody has better,easier way to handle this
Thank you for looking
I have a string coming in
its like abc def hsk nmps etc
My requirement is to remove any letter 'a' from the words within the string if it appears as the last letter
For example
"abc def abca" should be come "abc def abc"
"abc def' will not change
"abc nko 2090a sksa" becomes "abc nko 2090 sks"
so on and so forth
As you noticed the string can be of varying length including words
I am trying by looping the string ( unsuccessfully ) and wanted to see
if anybody has better,easier way to handle this
Thank you for looking
Update - Somebody suggested (not finding the post anymore ) using a trim function with 'T'
This helps because I can combine it with other logic to perhaps work it out
However , Trim( string,"a","T")
Trim with T option only seems to work for last words(in this case)
so
"abc def abca" becomes "abc def abc" (as expected)
but
"abc nko 2090a sksa" becomes "abc nko 2090a sks"
Thank you for suggestion
Still looking for options to handle that
This helps because I can combine it with other logic to perhaps work it out
However , Trim( string,"a","T")
Trim with T option only seems to work for last words(in this case)
so
"abc def abca" becomes "abc def abc" (as expected)
but
"abc nko 2090a sksa" becomes "abc nko 2090a sks"
Thank you for suggestion
Still looking for options to handle that
Try External Filter Stage with
Code: Select all
Filter sed
Arguements 's/a / /g;s/a$//g'
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You could create a loop in a Transformer stage that loops through the words. Treat the field as a space-delimited string, use Field() function to extract the individual words.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thank you for all your inputs , I have tested (more testing in progess ) it by applying space (trailing) and looking for 'a ' and replacing it with ' ' . I will also test using loops and external filter as suggested
Although , for looping , my logic greatly depends on the sequence of stage variables i am using for other transformation - so wanted to know , does a loop variable execute after the stage variables do ?
Although , for looping , my logic greatly depends on the sequence of stage variables i am using for other transformation - so wanted to know , does a loop variable execute after the stage variables do ?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: