How to do a substring to extract the last character of the string

Hi guys, I am new to UI Path and I am trying to do a substring to retrieve the last character of the string.

At present, the string is assigned as below:
author = “You searched for Author X”

I would like to extract the Author’s name → X and it is the last character of the string.

In order to do that, I would need to use substring.

First, I created a variable to store the length of the string, author.
length = author.length

Next, I did a substring as below.
authorname = author.Substring(length, length-1)

It returned an error saying that
Assign: Index and length must refer to a location within the string.
Parameter name: length

I don’t understand why I am getting this error. Can someone advise me?

u can try like this @samuel.goh

author.ElementAt(author.Length-1)

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like

Tried. It works! Thanks!

For using substring operation u can try like this

author.Substring(author.Length-1)

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed:

Mark it as solution so that we can close the topic

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