Home computickets as in a patern for RE.Findall shove the value of the variable...

as in a patern for RE.Findall shove the value of the variable [duplicate]




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?


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?

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions