If i have text in a string e.g. “Text1 - Text2” how do i specify i want to remove all text after the "-"so that i am just left with “Text 1”?
Why not buddy @jon1302 you can get all the text before - rather to remove after -
if we have like this text_variable = “Text1 - Text2”
then we can get with assign activity like this
text_variable = text_variable.Split(“-” c )(0).ToString.Trim
this would give you all the text that are before -
we wont have any words after -
Cheers buddy
Did that work buddy @jon1302
Cheers
Hello
I get an error: "Compiler error(s) encountered processing expression “stSupplierTitle2.Split(” - “)(0).ToString”. Option Strict On disallows implict conversions from ‘String’ to ‘Char’.
Put like this buddy @jon1302
ext_variable = text_variable.Split("-"c)(0).ToString.Trim
Now buddy…!
Awesome, working now thank you!!
Cheers buddy
Keep going
I modified so it is as follows: stSupplierTitle2.Split("-"c)(0).ToString
Though if i try to change “-” to " - " i get a message that the character constant can be only one character. Is there a way to make it work for more than one character?
Buddy the reason is T/A is not a character as character is a single word while - is a single character that should be actually mentioned in single quote. As we were mentioning that - in double quotes, we need to declare explicity as character. So we mentioned as "-"c
Here “T/A” is not a character, so remove that c nextto "T/A"c and just write as “T/A”
That would work buddy
Cheers
Thanks, i tried but giving a similar error to before:
Or try like this buddy
Split(stSupplierTitle2,“T/A”)(0).ToString.Trim
and may i know what is there before T/A buddy
Before T/A will be a company name e.g. DOT MANC LTD T/A FLORAL IMAGE MANCHESTER. So there will always be a space just before T/A. I tried the above but showing the following now:
THIS ONE IS WORKING BUDDY
Split(kout_string,“T/A”)(0).ToString.Trim
Not sure if i entered correctly:
remove that strSupplierTitle2 before split
and start with split alone buddy
I remove the kout and left with Split(stSupplierTitle,“T/A”)(0).ToString.Trim
Working now! Thank you so much for your help as always. You are awesome!
Cheers buddy
Keep going
I have a follow up question. In the above example the T/A is removed and all text after it. Would it be possible to modify so that T/A remains but all the text after is removed so e.g. “Text 1 T./A Text 2” becomes “Text 1 T/A”?
you can concatenate the text that you have taken as delimiters in split method buddy