How to copy exact 50 lines of code from a file when a timestamp is there

Hi, I have a text file in that text file I want to copy starting from a timestamp to 50 lines of code.
may consider the time stamp format is—[2020-11-27]. I will not copy the data before the timestamp.

Thank you in advance…

image
you can use regular expression, for example in the image above, i capture the first 20 lines after the first “[2020-11-27]” that is detected

You can use it in uiPath by assigning the following to a string
System.Text.RegularExpressions.Regex.Match(logText, "\[2020-11-27\] (.*\n){20}").Groups(0).Value

1 Like

Thank you so much, you save my day.

Hi, would you please tell me I want to select text from a particular text till pattern then can I do this, like I want to get text from [2020-12-17] to a pattern similar to this.
Would you please help me to build the regular expression

Waiting for your response.

can you be more specific? you want the text from [2020-12-17] to what text?

1 Like

Consider from [2020-12-17] to [2020-12-16]

im on my phone but heres a rough regex, im sure it can be improved. This captures text from the first [2020-12-17] to the last [2020-12-16]. Is this what you want?

\[2020-12-17\] (.*\n)+\[2020-12-16\].*\n

1 Like

Thank you so much. This is working. Thanks a lot.

1 Like

Your expressions are really helping, One thing more As I can see in the screenshot that expression selects till last occurrance of the [2020-12-16], if i need it to only select from [2020-12-17] till the first occurrance of the [2020-12-16] than how Can I do this?
Please help…
Thanks in advance.
Waiting for your response…

you can use the regex
(\[2020-12-17\] (.*\n)+?)\[2020-12-16\]

and capture group 1 instead of group 0 (meaning in uipath you use .Groups(1).Value instead of .Groups(0).Value

Again this regex can be improved, as i did this in a rush but hope it helps

1 Like

Thanks a lot. Your suggestions are really helpful.

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