I have a String which is(“Domestic-Travel - Non-Billable - Ground Transportation - Taxi - Amex”). Here, i want to check if the String is contains “hi-fen” or not and if it’s contains get the first word which is before ("-"). And if it’s not contains ("-") then search for the word “Amex” and get that word. Any help would be greatly appreciated…
It would be nice if you can give some sample inputs and outputs… try to include with “-” and without “-”
MyString contains the text, then use an If activity with condition
MyString.Contains("hi-fen"). To get the first word before the “-”, assign a variable to
System.Text.RegularExpressions.Regex.Match(".*(?=-)").Value. If the string for this match is
StrMatch, use an If activity in the Then block with condition
String.IsNullOrEmpty(StrMatch). If the condition is true, then find “Amex” with
I appriciate it bro. but is it possible without Regex !?
Which i have mentioned in my question that is the Actual String and if you see that at the last of that String there ia a word Amex.
for first scenario you can do below:
myString = "Domestic-Travel - Non-Billable - Ground Transportation - Taxi - Amex" log message = MyString.split("-"c)(0) >>> Domestic
log message = MyString.split("-"c)(1) >>> Travel and so on…
(Please specify which word)
Tell us what should be output for below strings:
“This is my test string Amex”
“This is my Amex test string”
Thanks @AkshaySandhu …Thank you very much for your help…
I am glad I could help…
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.