Forum Discussion
AssafHanina
06-27-2024Sisense Employee
hey JMANP00C ,
It looks like you want to remove the text pattern '[^a-zA-Z ]' from the Policy Owner Name column.
The Substring function slices a string from the beginning based on the index. Instead, please consider using the Replace All function to replace the specified pattern with an empty string.
Please find an Example:
- Open any Elasticube Data model
- Add Custom Table
- Paste the SQL Below and Preview the Outcome
select
example_a,
example_b,
example_c,
strparts(example_a,'$',1) as remove_before, -- strsparts which remove the text before the special character
strparts(example_a,'$',2) as remove_after, -- strsparts which remove the text after the special character
SubString(example_b,5) as sub_string, -- extract the substring based on the index
ReplaceAll(example_b,'[a-z,A-Z]','') as replace_with_empty_String, -- replace all occurroneces of the old string with new string.
ReplaceAll(example_c,'[a-z,A-Z]','$') as replace_with_special_charcater
from
(
select
'text_to_remove_with_special_charchater_$!@' as example_a,
'example_[a-z,A-Z]' as example_b,
'example_[a-z,A-Z]_test' as example_c
) a
Best Regards