Substring last character

HI Team,

Gota simple query in substring. I am looping a row and the item contains row values.
I want to print the last character in the line present in item. Thanks

Can you please share some sample texts and the output you want to extract?

@Balan

"Check as below

Hope this may help you

Thanks

Hi @Balan,

The suggested solution from @Srini84 will work.
I will add three other alternatives here for others who are interested.

  1. Captures letters to a string array and gets the last character
  2. Captures letters as characters and converts to array and gets the last character
  3. From the last character index gets the character
sample = "Dynamics"

1. sample.ToArray().Last

2. sample.ToCharArray().Last

3. sample(sample.Length-1)

Output
image

1 Like

I am extracting a row which contains text like
CNG 213 THIS IS MY NAME 12MAY2021 500.00 A

Above given text subject to change dynamically.
I want to extract the value A.
Last character A will be changing like C, P etc but it remains in the same position at the end of the line.

@Balan

What ever the last letter is it will always get using as below

Hope this may help you

Thanks

Use the Right function and just take 1 character.

1 Like

@Balan - Another option as suggested by @postwick

image

Tried using the below suggested code, but not working, returns blank.
sample.substring(sample.length-1)

I am looping some set of rows from mainframe
item contains
CNG 213 THIS IS MY NAME 12MAY2021 500.00 A
CNG 213 THIS IS MY NAME 12MAY2021 100.00 S
CNG 213 THIS IS MY NAME 12MAY2021 300.00 C

Expected output is in each loop it should return
A
S
C
Actual is message box returning blank

Hi,

There might be whitespace at the end of the string.
Can you try to put the following just before the above expression using Assign activity.

sample=sample.Trim

Regards,

1 Like