How to get the text after last semi colon (;)

How to get the text after last semi colon ( ; ) ?

Note : The count of the semi colon ( ; ) will change for each text. but we need to identify the last semi colon ( ; ) and get the text next to it

Sample texts :

1 . Passenger car ; Mercedes-Benz ; C-Class

  1. Passenger car ; VW ; EOS, GOLF, PASSAT; PASSAT CC, POLO; SHARAN

if you see there are 2 semicolons in this first text & 3 semicolons in this seond text

Hi @Sathish_Kumar_S

=> Assign -> StrVar = "Passenger car ; Mercedes-Benz ; C-Class"
=> Assign -> Output = StrVar.Split(";").Last.Trim

It will give the value after the last semi column.

Check the below image for better understanding.


Hope it helps!!

@Sathish_Kumar_S

Assign activity:
LastSemicolonIndex = InputText.LastIndexOf(“;”)

Assign activity:
LastText = InputText.Substring(LastSemicolonIndex + 1).Trim()

Hello @Sathish_Kumar_S ,
You can use the Following expression:
String_Variable=Input_Var.Split(";"c).Last
Hope this Helps
Regards;)

Hi @Sathish_Kumar_S

Try this using regex

(?<=;\s+)\w+\-?\w+$

I hope it helps!!

Hi @Sathish_Kumar_S

Try once with the regex !

1.StringVariable = System.Text.RegularExpressions.Regex.Split(" Passenger car ; Mercedes-Benz ; C-Class",“;”).Last

  1. StringVariable=System.Text.RegularExpressions.Regex.Split(“Passenger car ; VW ; EOS, GOLF, PASSAT; PASSAT CC, POLO; SHARAN”,“;”).Last

For the reference you can see the below screen shot.

unfortunately, the text next to last semicolon is not working for majority for click text activities.

We need to get all the text next to first semicolon

For Example : 1 : Passenger car ; VW ; Touran, T-Roc

We need only VW ; Touran, T-Roc from about input text

Hello @Sathish_Kumar_S, try this:

Dim inputText As String = “Passenger car ; VW ; EOS, GOLF, PASSAT; PASSAT CC, POLO; SHARAN”
Dim splitText As String() = inputText.Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
Dim lastText As String = splitText.LastOrDefault()

If Not String.IsNullOrEmpty(lastText) Then
’ Process the last text here
MessageBox.Show(lastText)
Else
’ No last text found
End If

Cheers :slight_smile:

Hi @Sathish_Kumar_S

if the ‘Passenger car ;’ is constant then you can use this regex pattern

stringvaraible = System.Text.RegularExpressions.Regex.Match(“Passenger car ; VW ; Touran, T-Roc”,“(?<=Passenger car ;\s).*”).Value

Hi @Sathish_Kumar_S

Please try this

Input.Split(";".ToCharArray,2).Last

I hope it helps!!

hey!Try this
inputText.Split(“;”.ToCharArray,2).Last
Hope it works

2 Likes

Hi @Sathish_Kumar_S

Have you tried this?

I hope you got the solution. If yes please mark it as solution to close the loop.