Extraction from UI Element

Hi,

I have a UI element as such: “0kg (-0.03kg)”. I want to extract only the “-0.03” and have an if condition to compare if it is less than 1.

Can you help me please?
Thanks!

Hi @Yudhisteer_Chintaram1

After extraction of UI element

Use the below assign activitiy to extract the data

digit = System.Text.RegularExpressions.Regex.Match(input, "(?<=\().*(?=\))").value

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

@Yudhisteer_Chintaram1 You can use regex to collect the desired data
https://regex101.com/r/9Dl2Wl/1

My element is assigned to a variable “text” like this:(for testing purpose only)
image

What is “input” in your code?

Thanks!

Hi @Yudhisteer_Chintaram1
as per your workflow, input is equal to text variable

Regards,
Nived N
Happy Automation

Hi @NIVED_NAMBIAR ,

Unfortunately I am having no output.

Can you help please?
Thanks"

@Yudhisteer_Chintaram1 - could you please show us your regex assign statement? and your ‘Open’ variable type?

System.Text.RegularExpressions.Regex.Match(text, “(?<=().*(?=))”).value

As advised by @NIVED_NAMBIAR

Hi:
Try this entry:

output = System.Text.RegularExpressions.Regex.Match(your_String,"(?<=\().*(?=kg)").Value

as @Arpit_Kesharwani suggest you.

1 Like

This expression returns the empty string…that’s why you are getting the empty ouptut…

Whenever there is () involved in the text you should escape it with \ or else it will not work…

Please check the below Regex pattern…

[-\d.]+(?=kg\))

image

1 Like

Hi @Yudhisteer_Chintaram1

Sorry , I typed correctly in forum but it appear in other way

Kindly check my response again

It is fine now

2 Likes

Thanks for the help:

Can you help me with this too please? They are related.

Thanks for the help.

Can you help me with this too please? They are related.

Hi,
Thanks for the help.

Can you help me with this too please?
They are related.

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