Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regular expression
#1
Hi, I have text data: Document
Output:
[DAT_23] system test //new_empty_line int a,n ( ); [CT-465775] [ END ]
We need to retrieve all the text and match the text from [DAT_23] system test //empty_line up to..... [ END ]

we can use re.search. Once we retrieve the whole text. Please reply and suggestions.
Reply
#2
I'm no expert but, since what you want to retrieve are a lot of lines, maybe you can just loop through the file lines, see if '[DAT_23]' is in one line, start retrieving, and then stop when you find '[ END ]'. If you think these substrings could actually appear somewhere else and "confuse" the program, you could use the regular expression to match them at the specific parts of the string (i.e. right at the beginning or end).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Regular Expression stahorse 9 1,523 Jul-31-2023, 01:20 PM
Last Post: Will_Robertson
  regular expression pramod 6 2,999 Jul-04-2020, 04:58 AM
Last Post: pramod
  regular expression pramod 4 2,080 Jun-16-2020, 02:01 AM
Last Post: pramod
  regular expression pramod 2 1,640 May-05-2020, 02:36 AM
Last Post: pramod

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020