How To select lines between specific words?

Hi, I need your suggestion
I use activities screen scraping output is in panel = Str.
Str = "Viewer Option Go to Page Copy File to Calendar Object Properties Find Requests
±--------------------------------------------------------------------------+
General Ledger: Version : 12.0.0
Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
Cause: FDPSTP failed due to ORA-01843: not a valid month
ORA-06512: at “APPS.KTC_CA002_LOAD_CARD_PKG”, line 261
ORA-06512: at “APPS.KTC_CA002_LOAD_CARD_PKG”, line 59
ORA-06512: at line 1
±--------------------------------------------------------------------------+
Concurrent request completed
Current system time is 27-NOV-2020 08:05:11

±--------------------------------------------------------------------------+
Enter Card Journals Cancelled
XXX - Enter Card Journals Cancelled"

But I want only line start with "General Ledger … until
line with "Current system time is "

Result should be only
Result = “General Ledger: Version : 12.0.0
Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
Cause: FDPSTP failed due to ORA-01843: not a valid month
ORA-06512: at “APPS.KTC_CA002_LOAD_CARD_PKG”, line 261
ORA-06512: at “APPS.KTC_CA002_LOAD_CARD_PKG”, line 59
ORA-06512: at line 1
±--------------------------------------------------------------------------+
Concurrent request completed
Current system time is 27-NOV-2020 08:05:11”

How can I do?
Thank you in advance

Use regular and pattern
(?=总分类帐)([\d\D]*)(?=(\d))

Could you please explain about command (?=总分类帐)([\d\D]*)(?=(\d)) ?
I’m not clear about it.

Try this
General Ledger: (.*\n)+Current system time .*

1 Like

Please check this Demo if it works, please mark it as resolved.Test.zip (49.9 KB)

Regex.Match(Str,“(?<=General Ledger:)(.|\n)*(?=Current system time is)”).Value

Try it!

I’m sorry , I can not open it cause of my version.

Thank you your answer is correct with my job.

May I ask about another?
if str = "General Ledger: Version : 12.0.0

Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.

KTCCA002 module: KTC - CA002 Load Card Journal via Excel
±--------------------------------------------------------------------------+

Current system time is 18-DEC-2020 09:18:22

Check Currency
Parameter CurrencyTHB
Value CurrencyTHB
Enter Card Journals
KTC - Enter Card Journals
9200331 Enter Card Journals Function List "

Result should be
Result = "General Ledger: Version : 12.0.0

Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.

KTCCA002 module: KTC - CA002 Load Card Journal via Excel
±--------------------------------------------------------------------------+

Current system time is 18-DEC-2020 09:18:22

Check Currency
Parameter CurrencyTHB
Value CurrencyTHB "

But I use
System.Text.RegularExpressions.Regex.Match(str,“(?=General Ledger: Version :)(.|\n)*(Enter Card Journals)”).Value

Result is
""General Ledger: Version : 12.0.0

Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.

KTCCA002 module: KTC - CA002 Load Card Journal via Excel
±--------------------------------------------------------------------------+

Current system time is 18-DEC-2020 09:18:22

Check Currency
Parameter CurrencyTHB
Value CurrencyTHB
Enter Card Journals
KTC - Enter Card Journals
9200331 Enter Card Journals Function List "

How can robot choose only first “Enter Card Journals”

Thank you in advance.

(?=General Ledger: Version :)(.|\n)*(Enter Card Journals)
=> (?=General Ledger: Version :)(.|\n)*?(Enter Card Journals)

Change pattern like this.
In this case, ? is important.
try it.

Thank you so much. Your code is work!!! :-]

1 Like

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