Dana is a string in which it is necessary to find a proposal or the word beginning and the end of which markers are indicated by markers that, in turn, are also known.
For example, in the string-‘What IS & GT; Apple & LT; ‘ or ‘What is & gt; an apple & lt;’ Pull out the words marked with markers “& gt; & lt;”
Here is my code:
import re
Def Between_Markers (Text: Str, Begin: Str, End: Str) - & gt; Str:
Stack = Re.Findall (R '[\ Begin \] \ W + [\ END \]', Text)
Return Stack
How in Paten-R ‘[]’ Write a function argument so that this argument is recognized?
Well, or how to find words or the word between the two arguments of the function, using the RE?
library
Answer 1
Strangely enough, but I myself found the answer to the problem itself, and not the question.
Return Text [TEXT.INDEX (Begin) +1: text.index (End)]
This line solves the entire task, but I still wonder how to enter variables into patterns?