on 06-23-2007 9:19 PM
Hi ,
I have a string coming in which looks like this
abcdeefghijkl#ksjdakfjasf#ajshdfakl~.
For each occurence of # or ~ I am suppose to introduce a context change and hence create a new line and # oe ~ has to be replaced with ' '.
Can anyone help me out with a udf .
Regards
Deepak
Sharma,
Check this weblog for some help:
/people/dennys.hsieh/blog/2006/11/20/how-to-parse-xxyyzzaabbcc112233-in-message-mapping
You can use the UDFs which defined in this weblog to solve your issue.
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Deepak,
StringTokenizer st = null;
for(int i=0;i<input.length;i++)
{
st= new StringTokenizer(input<b>[</b>i<b>]</b>,"#~");
while (st.hasMoreElements())
{
result.addValue(st.nextElement());
}
result.addContextChange();
}
For exampe if the input is
abcd#efgh#ghji~klm
1234#56789890432
then you will get the o/p as
abcd
efgh
ghji
klm
<b>[contextchange]</b>
1234
5678
9890
432
Hope it helps!!!!
Best regards,
raj.
Deepak,
The only difference btw my code and ur argument is a. In my code I used input as the argument, did u changed that.
Change your argument <b>a</b> to <b>input</b> or change the code <b>input</b> to <b>a</b>.
If still u get errors, kindly tell me the error details.
<b>Note:</b> Sorry I forgot to say ,import java.util.*;
Best regards,
raj.
Message was edited by:
Raj
Actually I did change it (input) to a ..
Now the code looks like this
import java.util.*;
StringTokenizer st = null;
for(int i=0;i<a.length;i++)
{
st = new StringTokenizer(a<i>,"#~");
while(st.hasMoreElements())
{
result.addValue(st.nextElements());
}
result.addContextChange();
}
the error that I am getting is illegal start of expression
import java.util.*;
I have just added this line import java.util.*;
at the top of the code inside the fm
StringTokenizer st = null;
String var="";
for(int i=0;i<a.length;i++)
{
st= new StringTokenizer(a<b>[</b>i<b>]</b>,"#~");
while (st.hasMoreElements())
{
var =(String)st.nextElement();
result.addValue(var);
}
result.addContextChange();
}
//Note : U used st.nextElements(), in ur UDF see my UDF in the first , actually the result.addValue expects string , hence I typecasted into string. Copy and paste the above code it works pefectly.
Best regards,
raj.
Deepak,
Can u give the structure?
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.