Hi,
Can some one tell me how can i search a substring from behind,(i want to search for the 1st space from the end of a string)
E.g. i want to split a note of more than 100 characters into 40 chars each. While doing so i want logically split the note, that means instead of truncating at the 40th Char i want to trunacte till the last space in the 40 cars
input String = 'Can someone tell me how can i search a substring from behind'
i want the first 40 chars until the last space
Expected output= 'Can someone tell me how can i search a '
I dont want 'Can someone tell me how can i search a s'
instr in datastage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 31
- Joined: Mon Jun 28, 2010 5:15 am
- Location: pune
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
By far the easiest way to accomplish this task is to use "text formatting", to do which you need to use the Fmt() function in a BASIC Transformer stage (or in a server job).
The derivation expression is
The Fmt() function with "T" in its second argument produces a dynamic array delimited by text marks (@TM) containing substrings of not more than the specified length, broken on word boundaries. So if you need the other 40-character-or-less substrings, simply change the third argument of the encapsulating Field() function.
The derivation expression is
Code: Select all
Field(Fmt(InLink.TheString,"40T"),@TM,1,1)
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.
-
- Participant
- Posts: 31
- Joined: Mon Jun 28, 2010 5:15 am
- Location: pune
-
- Participant
- Posts: 102
- Joined: Thu Sep 17, 2009 1:23 am
instr in datastage
BASIC transformer is not visible in the Proccesing palette in Parallel job. Hence we would need to bring in the BASIC transformer to our design canvas following the steps stated below:
Go to Repository tree -> Stages Types -> Parallel -> Processing -> BASIC Transformer.
Drag and drop the BASIC transformer stage to our design canvas.
Go to Repository tree -> Stages Types -> Parallel -> Processing -> BASIC Transformer.
Drag and drop the BASIC transformer stage to our design canvas.
Rohit
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
I wrote a Parallel Routine tro do a similar task - search for pxStrFirstCharList for the version that finds the first occurrence of a character in a set of characters, it should be easy to create a version that finds the last, I did make one but I don't have the source for that to hand.
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant