Extract values using Substring

studio
variable

#1

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. >>
001
Shirt
S
Blue

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


#2

Hey @savithrin

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

if still will face problem, Let us know.

Regards…!!
Aksh


#3

@savithrin

Check attached File

SubstringRemove.zip (1.9 KB)


#4

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.
image

Can any one help me :roll_eyes:


#5

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


#6

hi,

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:


#7

Can you tell me how to to that :roll_eyes:


#8

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

Arrvalue=Item.Split(":"c)
Push the value into Dictionary
Key=arrValue(0) and Value=arrValue(1)

image

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

Regards,
Arivu


#9

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.


#10

Substring sample.xaml (8.2 KB)


String manipulation - read all words between two hashes ##
#11

thanks all now it works perfectly :smiley: