Remove string after delimiter
Hi Team,
Looking for help here on how to remove all string after a delimiter.
For example i have a data with the value: ht/w.domaindomain.c/pathpath
and i want to remove all the strings after the delimiter last '/'
the results would be : ht/w.domaindomain.c
Please assist. Thanks!
Best Answer
-
Hi,
To add to Manuel's solution. If you already know the pattern, you can use the similar Regex approach but with Find and Replace processor like below:
Best,
Vitaliy
Answers
-
Manuel Alpha Tester, Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 193 ✭✭✭✭✭✭✭
Hi,
In a Prepare recipe, use the Smart Pattern Builder to extract the text, as explained in this page, https://knowledge.dataiku.com/latest/courses/advanced-data-prep/prepare-recipe/smart-pattern-builder.html
I hope this helps.
Best regards
-
Thank you both on providing the solutions! It works for me!
-
Hi VitaliyD,
Would you be able to explain further on what does the logic really saying?
(^.*)(\/.*) and replace by $1 ?
-
Hi @imransaiful17
,With this regex expression, we are forming two groups including everything before the last forward slash and everything after and then taking the second group and output as the value in the cell.
If you are looking for a more detailed explanation of the regex, there are many resources on the internet available. The one I use mostly for regex expression testing is https://regex101.com/. If you copy-paste the expression into the regular expression field, you will see a good explanation of what the expression does in the right pane.
Hope this helps,
Best,
Vitaliy