Python Forum

Full Version: regular expression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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).