I have multiple keywords in array and want keyword which occurs last in the input string

I have one array which can consists some values. So i want to find value which occurs at the end of the string.
Example:

Input array:
{SBI,AXIS,ICICI}

Input string:
" Transaction from SBI bank, sender is ICICI AND RECEIVED TO AXIS BANK"

Output:
AXIS

EXAMPLE 2:
“RECEIVED TO AXIS bank from sender SBI to ICICI BANK”

Output:
ICICI

Can we do that without loop…?

hI @Mansi_Mhatre

Try this to get last value from the array
Textfile = {SBI,AXIS,ICICI}
TextFile(TextFile.Length-1)

Here is the SS

image

Regards
Gokul

Hi,

Can you try the following?

inputArray.Where(Function(s) yourString.Contains(s)).OrderByDescending(Function(s) yourString.LastIndexOf(s)).FirstOrDefault

Regards,

Hi @Mansi_Mhatre

Correct me if i’m wrong: You have an input array of bank names, you want to know which one is mentioned last in the string?

Give @Yoichi’s answer a go.

Otherwise another way you can do it, assuming your string always ends with BANK you can use split. i.e. strText.Split(" "c)(strText.Split(" "c).Length - 2)

Kind Regards

Thanxx…

I have one more query…
I have string which contains large data, so i want to replace number part with ’ before number.

I am getting csv data in the form of semicolon seperator so while converting that text file to excel. Initial 0 is eliminated after saving file.
So i want solution for this issue.

So if not found then want to convert each only number between semicolons to ’ number.

Sample input string:
Abc;thseh4566;00089990088;updateform;56783pdfd;9876;Bankname

Output:
Abc;thseh4566;'00089990088;updateform;56783pdfd;'9876;Bankname

It should replace 00089990088 and 9876 with '00089990088 and '9876.

Hi,

The following will work. Can you try this?

System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=;|\n)(?=\d)","'")

Regards,

Please explain this query for improve learning

Hi,

Which query, in post #3 or #6?

Regards,

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