How to extract a paragraph from text file based on condition

Email Format.txt (2.7 KB)
Here is email format file given , i want to get paragraph according to temperature range and extracted text i want to email according to temperature of city.

Can you share the expected Output @Vidhi_Patel

1 Like

ExpectedEmailFormat.txt (438 Bytes)
Here it is. if city temperature is 30 degree then it will be output.

I can’t able to get you @Vidhi_Patel . Can you share the Input. Based on the input share the expected Output

1 Like

i’m getting city name and email address from user and then getting temperature from google search temperature value in a string variable now i want get particular paragraph according to temperature from EmailFormat file below:-
Email Format.txt (2.7 KB)

Okay Understood. What is the issue your are facing while automating @Vidhi_Patel

1 Like

I’m not able to get which condition I should put to solve this , i have prepared regex to get Dynamic values in EmailFromat file but how i should use condition , can i use switchcase but then how can i compare a temprature(String type) with the temprature range(mentined in format file) giving with the input file. Can you give me some hints. i get stuck.

You can try with Else If condition @Vidhi_Patel

image

Check out the docs & Video

https://docs.uipath.com/activities/docs/else-if

Regards
Gokul

1 Like

Thank you understood. @Gokul001


Here according to condition i only want to extract first paragraph which include guide for o to 5 degree temperature. how ever my regex extracts all the Materials,Key Pieces,ACCESSORIES. Here is Schreenshot my regex below.

Regex: /(?=0 – 5).|(?=MATERIALS:).|(?=KEY PIECES:).*|(?=ACCESSORIES:).

What is the Output for this regex pattern?

You can Add another Else if for all the paragraph

image

Regards
Gokul

@Gokul001
Screenshot (4)|690x388
Instead of 1 paragraph i get all the paragraph in output! :frowning: @raja.arslankhan

@Vidhi_Patel are you want just one paragraph from file

1 Like

Yes for first condition if temp equal to 0 to 5 , i need only first paragraph for clothing guide.

Instead of this regex You can try with

(?=\d)+[A-Za-z\d\D\n\W].+\n.+\n.+\n.+

Regards
Gokul

Got it @Gokul001 :slight_smile: , Thanks a lot ! will change starting expression for every case!


however that doesn’t support in uipath regex! i don’t know why!

hi @Vidhi_Patel

How about this expression?

System.Text.RegularExpressions.Regex.Match(YourString,"(?=\d)+[A-Za-z\d\D\n\W].+\n.+\n.+\n.+").Tostring

Or

Instead of Ismatch activity use it in Assign activity

System.Text.RegularExpressions.Regex.IsMatch(YourString,"(?=\d)+[A-Za-z\d\D\n\W].+\n.+\n.+\n.+").Tostring

Regards
Gokul

1 Like

while specifying (?=0 – 5 ) instead of (?=\d) i still face following error . it works well in regex editor in website but didn’t work for uipath!


with regards Vidhi

Hi @Vidhi_Patel

You can try like this

0 – 5[A-Za-z\d\D\n\W].+\n.+\n.+\n.+

Regards
Gokul

2 Likes
System.Text.RegularExpressions.Regex.Match(YourString,"0 – 5[A-Za-z\d\D\n\W].+\n.+\n.+\n.+").Tostring

Or

System.Text.RegularExpressions.Regex.IsMatch(YourString,"0 – 5[A-Za-z\d\D\n\W].+\n.+\n.+\n.+").Tostring

Still this expression doesn’t work in assign activity but also not giving proper output in ismatch activity as well.


With Regards Vidhi