Hi All,
I have a requirement where I have to capture the string from a line after a space in the reverse order.
eg: 1) james alex 1234 usa
2) johnny beck abc 1234 canada
output should be:
1)usa
2)canada
note: The number of spaces are not constant.
I tried to use the index function by mentioning the negative value like index(inputcol," ",-1) ,substring and field fucntion, but this is not working. Is there any simple way to implement this.
Thanks
NJ
Using Index function
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
In your example,you have to count then apply field function.
eg: 1) james alex 1234 usa
Count(input," ") - 3
Count1- Count+1
Field(line," ",count1)
1)usa
eg: 1) james alex 1234 usa
Count(input," ") - 3
Count1- Count+1
Field(line," ",count1)
1)usa
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Hi Bob,
Your solution is working for the requirement that i mentioned in the post, thanks for that, but i forgot to mention complete solution that I am looking. Below is how i want the output to be
eg: 1) james alex 1234 usa
2) johnny beck abc 1234 canada
output (1)should be:
1)usa
2)canada
output(2) should be:
1)james alex 1234
2)johnny beck abc 1234
Please let me know if this makes sense.
Thanks
NJ
Your solution is working for the requirement that i mentioned in the post, thanks for that, but i forgot to mention complete solution that I am looking. Below is how i want the output to be
eg: 1) james alex 1234 usa
2) johnny beck abc 1234 canada
output (1)should be:
1)usa
2)canada
output(2) should be:
1)james alex 1234
2)johnny beck abc 1234
Please let me know if this makes sense.
Thanks
NJ
If you know how to take the last field, to get everything up to but not including the last field use "1, dcount-1" where you have "dcount" right now. For example:
Last field:
All other fields:
Last field:
Code: Select all
Field(YourField, " ", DCount(Yourfield," "))
Code: Select all
Field(YourField, " ", 1, DCount(Yourfield," ")-1)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers