Removing certain words fro the given sentence

Hi UiPath Community,

Text 1 =the business-type activities and the aggregate remaining fund information of the Housing Authority of the County of Alaska (the “Authority”), as of and for the year ended June 30, 2023,
output = the business-type activities and the aggregate remaining fund information of the Housing Authority of the County of Alaska (the “Authority”)

Text 2 =the governmental activities and each major fund of the Tribe (the “Tribe”), as of and for the year ended December 31, 2022
Output = the governmental activities and each major fund of the Tribe (the “Tribe”)

From the given text 1 and 2 i need to remove keywords starting from “as of” in the given text, please help me to find the solution

Regards,
Alan

Hi @alan.prakash

Assign -> Input: "the business-type activities and the aggregate remaining fund information of the Housing Authority of the County of Alaska (the “Authority”), as of and for the year ended June 30, 2023"

Assign -> Output = System.Text.RegularExpressions.Regex.Replace(Input,"as\s*of[\s\S]*?\d{4}","").Trim().Replace(",","")

Hope it helps!!

@alan.prakash

For Text 2 also same expression will work:

Assign -> Input: "the governmental activities and each major fund of the Tribe (the “Tribe”), as of and for the year ended December 31, 2022"

Assign -> Output = System.Text.RegularExpressions.Regex.Replace(Input,"as\s*of[\s\S]*?\d{4}","").Trim().Replace(",","")

Regards

If you need remove everything after as of use System.Text.RegularExpressions.Regex.Replace(text, “, as of.*”, “”)

If you need to check till the year and then remove it, use previous response.

Hi @alan.prakash

Try this

New String(Input.TakeWhile(Function(c, i) Not Input.Substring(i).StartsWith(", as of")).Select(Function(c) c).ToArray()).Trim()

Cheers!!

You can use split function here
Assign Text1,Text2 as string type variable
Assign variable as array of string as Output_Text1 and Output_Text2
Output1 =Text1.split(","c)
Use Output1(0).tostring you will get the output of text1 prior to “as of”
I used text1 randomly but we have same “,” before as of of your text.

Thanks for the reply i got the solution

1 Like

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