Get string after first occurance of word

Hello.

I have a string like

Pocetni string. Follow up Q4 2024: Implementacija lokalnih firewall-ova jos nije sprovedena Implementacija lokalnih firewall-ova

How can I get substring before first occurance of Follow up Q4 2024?

To extract the substring before the first occurrence of Follow up Q4 2024 in UiPath, you can use the Substring and IndexOf methods in an Assign activity. Here’s how you can do it:

Steps:

  1. Store the String:

    • Use a String variable (e.g., inputString) to store your full string:
      Pocetni string. Follow up Q4 2024: Implementacija lokalnih firewall-ova jos nije sprovedena Implementacija lokalnih firewall-ova
      
  2. Find the Index of the Keyword:

    • Use inputString.IndexOf("Follow up Q4 2024") to find the position of the first occurrence of Follow up Q4 2024.
  3. Extract the Substring:

    • Use inputString.Substring(0, inputString.IndexOf("Follow up Q4 2024")) to get the part of the string before the keyword.

Example Implementation in UiPath:

  • Variables:

    • inputString (String): Contains the full string.
    • resultString (String): To store the extracted substring.
  • Assign Activities:

    1. inputString = "Pocetni string. Follow up Q4 2024: Implementacija lokalnih firewall-ova jos nije sprovedena Implementacija lokalnih firewall-ova"
    2. resultString = inputString.Substring(0, inputString.IndexOf("Follow up Q4 2024"))

Final Result:

resultString will contain:

Pocetni string. 

Let me know if you need further assistance!


Pattern: .*(?=Follow up)

Assign Activity:
strSubString = System.Text.RegularExpressions(yourStringVar, ".*(?=Follow up)").Value

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

With extension to the Quarter / Year part

Great, thank you for your help :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.