Remove string after delimiter

imransaiful17
imransaiful17 Registered Posts: 10 ✭✭✭✭

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

  • Vitaliy
    Vitaliy Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 102 Dataiker
    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:

    Screenshot 2021-09-30 at 14.27.44.png

    Best,

    Vitaliy

Answers

  • Manuel
    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

  • imransaiful17
    imransaiful17 Registered Posts: 10 ✭✭✭✭

    Thank you both on providing the solutions! It works for me!

  • imransaiful17
    imransaiful17 Registered Posts: 10 ✭✭✭✭

    Hi VitaliyD,

    Would you be able to explain further on what does the logic really saying?

    (^.*)(\/.*) and replace by $1 ?

  • Vitaliy
    Vitaliy Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 102 Dataiker

    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

Setup Info
    Tags
      Help me…