Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

search and copy code from html page

Hi all,
I am loading a page into twebbrowser and I need to do the following:

The document (from the top) starts with a <!DOCTYPE and ends with a > I need to copy that into a variable (string)

Here is an example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Above is the begining of the html file ... I need to copy from the beginining <!DOCTYPE to the ending  > nothing else.

Hope you can help! thanks.

p.s: I'm actually using TEmbeddedWB but it's the same as TWebBrowser ...

thanks

st3vo
0
ST3VO
Asked:
ST3VO
  • 4
  • 2
1 Solution
 
epasquierCommented:
yep, always the same thing. do you want to use a function or a regular expression ?
0
 
ST3VOAuthor Commented:
If you can explain the regular expression and it's easy to understand then the regular expression otherwise a function would do please

0
 
epasquierCommented:
I certainly won't explain regular expressions. they are things that are either learned by themselves or never done alone. If you are interested in understanding the regular expressions, check the document he added in his response of your previous post. It's all there, but when we said it at e steep learning curve it was probably an understatement.
If you are not that interested then learn how to do it with algorithmic skills and PosEx and Copy, that's all you need (I mean you could use some more elaborate string functions that do much complex operations, but those 2 are all you need to have to do string analysis and modifications.
The functions I already gave you show an example of how to do it
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
epasquierCommented:
I'll see tomorow or monday If I can do it for you on this problem, I realy have to go now
0
 
epasquierCommented:
SearchBetweenAndCopy(Str,'<!DOCTYPE','>');
function SearchBetweenAndCopy(Str:String; const StrBefore,StrAfter :String) :String;
Var
 P,P2:Integer;
begin
 P:=Pos(StrBefore,Str);
 Result='';
 if P>0 Then
  begin
   P:=P+Length(StrBefore);
   P2:=PosEx(StrAfter,Str,P);
   if P2>P Then 
    begin
     P:=P-Length(StrBefore);
     P2:=P2+Length(StrAfter);
     Result:=Copy(Str,P,P2-P);
    end;
  end;
end;

Open in new window

0
 
ST3VOAuthor Commented:
Perfect! Thanks :o)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now