on 02-22-2013 6:45 PM
Hi Sdners,
I have a requirement where my input field max length is 10 characters. If the length is less than 5 characters I need to take the five characters and if the length is ten characters, after first five characters I need to put '\' symbol.
Example:
input a = 12345 output b = 12345
input a = 1234567890 output b = 12345/67890.
Can anybody help me in writing UDF for this requirement.
Thanks in Advance.
Regards,
Ram.
Hi Ram,
You can try like below:
String grtChar;
for(int i=0;i<input_str.length;i++)
{
if (input_str[i].length() < 6)
{
result.addValue(input_str[i]);
}
else if (input_str[i].length() < 11)
{
grtChar = input_str[i].substring(0,5) + "/" + input_str[i].substring(5,10);
result.addValue(grtChar);
}
else
result.addValue("");
}
Please find the attached screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> If the length is less than 5 characters I need to take the five characters
?? Elaborate your query please.
> if the length is ten characters, after first five characters I need to put '\' symbol.
-Check length if its > 5
-Substring 0-4
-Set a constant '\"
-Concat
These are your requirements ?
Regards,
Sunil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.