S
S
Shaunluu2016-12-16 21:21:06
Python
Shaunluu, 2016-12-16 21:21:06

How to find the desired text in a string, between characters?

Good evening!
Tell me how to implement the function in python:
We have text on the page -

-----AAAaaaaAAAf-----<br />	
текст овер 300 знаков<br />
-----AAAaaaaAAAf -----<br />

Take out from the string everything that is between -----AAAaaaaAAAf -----<br />and <br />
There was a good function on Delphi
function Pars(T_, ForS, _T: string): string;
var
  a, b: integer;
begin
  Result := '';
  if (T_ = '') or (ForS = '') or (_T = '') then  Exit;
  a := Pos(T_, ForS);
  if a = 0 then    Exit
  else  a := a + Length(T_);

  ForS := Copy(ForS, a, Length(ForS) - a + 1);
  b := Pos(_T, ForS);
  if b > 0 then Result := Copy(ForS, 1, b - 1);
end;

In it, you could easily get what you need by calling it:
text:= Pars(' MESSAGE -----<br />',str,'<br />');
Maybe someone has an analogue of this function for python?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question