Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a requirement where I want to combine multiple same consecutive characters in a string into one.
Lets say for eg I have a string value as : ____1__2_abc_____hhv
I want to check if same character (in my case underscore) is appearing consecutively in a string and combine it into single character.
Final output should be like : _1_2_abc_hhv
Any help would be appreciated
Regards,
Aditya
Hi
Try this
temp:
Load SourceString,
SubField(SourceString, '_') as OneValue
Inline [
SourceString
" ____1__2_abc_____hhv"
" ______5__7_abc____lmn"
" ___9__8___def___ijk"
];
NewTable:
LOAD SourceString,
Concat(distinct OneValue, '_') as CleanString
Resident temp
Group by SourceString;
DROP Table temp;
Hi,
You can try a solution like this. Maybe there is a better solution
_map:
Mapping LOAD
test,
'_' as new
Inline [
test
______
_____
____
__
];
LOAD
test,
MapSubString('_map', test) as test4
Inline [
test
____1__2_abc_____hhv
____2__RT_sdfsdf____e
];
Hi
Try this
temp:
Load SourceString,
SubField(SourceString, '_') as OneValue
Inline [
SourceString
" ____1__2_abc_____hhv"
" ______5__7_abc____lmn"
" ___9__8___def___ijk"
];
NewTable:
LOAD SourceString,
Concat(distinct OneValue, '_') as CleanString
Resident temp
Group by SourceString;
DROP Table temp;