Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
I have a string 01#345@78$
How to change the special characters (#,@,$) to 2,6,9 respectvely from the string?
I tried with using replace function but didn't work properly
Any ideas?
map1:
mapping load * inline [
#, 2
@, 6
$,9
] ;
Data:
LOAD *,
MapSubstring ('map1', F1) as new
INLINE [
F1
01#345@78$
];
Result:
See the attachement.
You can use Replace or MapSubstring functions.
=replace(replace(Replace('01#345@78$', '#', 2), '@', 6), '$', 9)
Well Replace works fine.
Result:
Thanks but how can we do by using MapSubstring function?
It showing only two parameters map_id and text.
May be like this:
MappingTable:
Mapping
LOAD * Inline [
From, To
#, 2
@, 6
$, 9
];
FactTable:
LOAD FieldName,
MapSubString('MappingTable', FieldName) as NewFieldName
FROM Source;
Hi Satish,
Hope you are asking for dynamic expression. If so, try below expression,
=Replace(
Replace(
Replace('01#345@78$',
'#',Mid('01#345@78$',Index('01#345@78$','#')-1,1)+1),
'@',Mid('01#345@78$',Index('01#345@78$','@')-1,1)+1),
'$',Mid('01#345@78$',Index('01#345@78$','$')-1,1)+1)
map1:
mapping load * inline [
#, 2
@, 6
$,9
] ;
Data:
LOAD *,
MapSubstring ('map1', F1) as new
INLINE [
F1
01#345@78$
];
Result:
See the attachement.
Hi Satish,
You can try this
Thanks for all your ideas...
One more version..
Load Concat(Out,'') As text2;
Load *,
Alt(Mid(text,IterNo(),1)*1,IterNo()-1) As Out
Inline [
text
01#345@78$
]
While IterNo() <= Len(text);
text2 will have 0123456789