Remove text from string


I need the only 3 characters before ‘—’ remove rest of the text…
example: “abc def ATA — All Time After”

in the above example i need only ATA — All Time After this part ,remove ‘abc def’

and also remove the text if there is no in the text…
eg: All Time After i want to remove the whole text…if there is no hypen…(—)

please send me the if condition for this…


Assign Activity
Name=System.Text.regularexpressions.regex.replace(“abc def ATA — All Time After”,"-","").tostring

Hi @suresh_kumar4,

Check the below image, it will help you to extract the expected string from that text.

1 Like

Thanks @sarathi125 ,

Need one more help if the text does not contain ‘_’ i want to remove the whole text…
so how can i do that…



Check with this,

IF(strInput.Contains("—"), strInput.Substring(strInput.IndexOf("—")-4, 3).Trim(), string.Empty)

sorry i am not getting…the output…



Check the below image, and I am checking the Character you have mentioned in the initial post, not the underscore, so ensure your input is correct.


This is working outside the for each loop…

inside the loop i am getting error…

can you help me on this,


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