on 10-03-2007 7:43 AM
Hi All,
In one of our field Name "Index_Name". we are having given value as seen in the following example.
<b><u>Source Side:</u></b>
<Index_Name>OP-A-010SCM-OP AVG CLR SPR 9.0 </Index_Name>
<Index_Name>OP-A-010SCMP-OP AVG CLR SPR 9.0 </Index_Name>
I want send the value before third one "-" in target structure like.
<b><u>Target side:</u></b>
<Index_Name>OP-A-010SCM </Index_Name>
<Index_Name>OP-A-010SCMP </Index_Name>
then how can i do that.
Thanks
Anuj
Some times I am getting 11 characters and some times I am getting 12 char before "-". So I coudn't use substring correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anju Agarwal ,
I misunderstood your question . Will -op always will come at end of string ?
If so , read the string before "" space . Then find the index of -op then read the string prior to that .
Regards.,
V.Rangarajan
null
Message was edited by:
ranga rajan
Message was edited by:
ranga rajan
Hi Anju,
try this mapping....
Name is the source node.
URL is the target node.
substring is the user defined function.
Constant should have the value "-".
Mapping: http://www.flickr.com/photos/11767150@N03/1475708348/
UDF: http://www.flickr.com/photos/11767150@N03/1475709374/
This searches for the last occurance of "-" and extract the string before it.
Regards
San
Hi Anju ,
As refer to Monika's reply. Please change the following . It will surly help .
-
String source="OP-A-010SCMP-OP AVG CLR SPR 9.0";
<b>int index=source.indexOf(" ");
String target=source.substring(0, (index-3));</b>
System.out.println(target);
-
<b>Output is :</b> OP-A-010SCMP
Assign points if u found helpful
Regards.,
V.Rangarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
This logic works for all length of source string
public void check()
{
String source="OP-A-010SCMP-OP AVG CLR SPR 9.0";
int index=source.indexOf("-OP");
String target=source.substring(0, index);
System.out.println(target);
}
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thanks for your reply. But always I am not getting -OP in last. some times i am getting -PL also. is it possible to count "-"??
PL-H-AABHK00-PL
PL-H-AADDV00-PL
OP-A-010TRC-OP
OP-A-010UCM-OP
Because I have to send the value in to the target before third "-".
I don't know the java. So can u tell me proper UDF?
Thanks
Anuj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi anju,
I tried with the mapping with what i sent u and it is executing successfully.
I assume that there is only 3 "-" is your source and u want to extract the string before the thitd hypen which is going to be the last hypen.
If this is the case this mapping will work perfectly...
Regards
San.
hi anuj,
since it is variable string length you cannot use substring. what you can do is write a small UDF with the following logic
you have to search for the occurence of "-OP" in the source string which should return the index of "-" in "-OP".
After this you get the substring value and then you can extrace the required string.
Hope this is helpful
Regards
Ramesh P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anuj,
As suggested by experts u will have to write UDF
here is the logic
Read your string.. when you encounter pattern '-OP' ignore rest of the string..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can also do an User-Defined-Funtion for more powerful, for example like this:
imports java.lang.String;
int begin =0;
int end = 0;
try {
begin = Integer.parseInt(a);
end = Integer.parseInt(b);
}
catch(NumberFormatException e) { }
return (c.substring(begin,end));
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use substring of text functions in the message mapping
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use <b>subString()</b> function and try ignoring rest of the string..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anuj,
U can use substring standard function for that
input->subtring(0,11)->output
try this...
regards
BILL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.