Extract values using Substring



Hi all,

I am a beginner to RPA. I want to Extract some values using Substring.

ID: 001
Brand: Shirt
Size: S
Color: Blue

I want to get only below values separately. >>

Can anyone help me ??
Thanks in Advance :slight_smile:


Hey @savithrin

Refer below thread and u will be able to get some idea about it.

if still will face problem, Let us know.




Check attached File

SubstringRemove.zip (1.9 KB)


Hi ,
Thanks for the help. But now i am facing another problem.
In my case I am getting above mentioned data from a PDF using read PDF text. variable name = pdf1.

test1_id = Split(pdf1.ToString , “:”)
output = test1_id(test1_id.Length-4)

When I print the output variable, it shows the value as this.

Can any one help me :roll_eyes:


you have to split first your string with Newline then you will be able to use what you have done.



The thing is am getting those data from a pdf. So I think I cant use your method. Anyway thanks for the great help :slight_smile:


Can you tell me how to to that :roll_eyes:


Hi @savithrin,

StrValue=" ID: 001
Brand: Shirt
Size: S
Color: Blue"

ArrNewline-> string[]
ArrNewline=StrValue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

Use for each activity

Push the value into Dictionary
Key=arrValue(0) and Value=arrValue(1)


dictPromoData(“Brand”) -> you will get the value as “Shirt”
Refer this post



Nice example.
Don’t forget to add .Trim calls or change Split(":"c) to .Split(": ") (without c qualifier, as then we’re splitting by actual string, not char) , otherwise you’ll have leftover whitespace in the values (and possibly keys as well, depending on original string).

PS. You’re adding a lot of code to the forum, it would look better and be safer (and easier to copy) if you’ll put them in code tags or backticks.


Substring sample.xaml (8.2 KB)

String manipulation - read all words between two hashes ##

thanks all now it works perfectly :smiley:


Hi everyone.

I am trying to extract data from a text file. I am using substring while looping through each line in text file.

Now the problem is , in text file. Under comments, some lines has data in comments field and some doesnot. Its failing if the comments is blank.

Do you guys have any approach , how to handle such exceptions in substring


would you mind to give us some text example?

If you are reading a CSV with some quotes:

Text Example:

My preffered way its just erase all quotes with a line.Replace(""",string.empty)

If this is not your case, give us an example :slight_smile:


sAMPLE DATA.zip (859 Bytes)

I need to convert this text file into excel. You can see that in third row, comments column is blank. I used this approach to use substring to read each column value. But its failing for comments column. Any another approach?