Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi String: Copy, Pos (https://www.delphipraxis.net/10805-string-copy-pos.html)

Pseudemys Nelsoni 25. Okt 2003 17:12


String: Copy, Pos
 
hoi, ich muss bestimmte zeilen aus einem string kopieren, sie können in der menge beliebig sein, alles was vor und nach diesen zeilen ist soll gelöscht werden...das ist der text:

Code:
<html>

<head>

   <title>CNC Reloaded - Battle Clans</title>

</head>

<body>

<center>

<h1>CNC:R Tiberian Sun Battle Clans</h1>

<h2>Text-Only version</h2>











<h3>Administrate Battle Clans</h3>

<table border="0" cellspacing="0" cellpadding="0">
<td width="200">

<font size="4">Clan name:</p></font></td><td width="400">

<font size="4">Best game ever</p></font></td><tr>
<td width="200">

<font size="4">Abbreviation:</p></font></td><td width="400">

<font size="4">TS</p></font></td><tr>
<td width="200">
</td><td width="400">
</td><tr>
<form action="clan.php?action=kick_member" method="POST">
<input type="hidden" name="admin_pass" value="00000000">
<input type="hidden" name="clan_name" value="TS">
<td width="200">

<font size="4">Kick member:</p></font></td><td width="400"><select name="kick_mem">

<option name="hehe">hehe</option>
<option name="haha">haha</option>
<option name="LooL">LooL</option>
<option name="keke">keke</option>
<option name="huhu">huhu</option>
<option name="lalilu">lalilu</option>
<option name="sudnevo">sudnevo</option>
<option name="heinz">heinz</option>
<option name="tcclanplz">tcclanplz</option>
<option name="uwe33">uwe33</option>

</select><input type="submit" value="Kick"></td></form>
<form action="clan.php?action=chage_motto" method="POST">
<input type="hidden" name="admin_pass" value="02580258">
<input type="hidden" name="clan_name" value="TS">
<td width="200">
</td><td width="400">
</td><tr>
<td width="200">

<font size="4">Motto:</p></font></td><td width="400">

<font size="4">TS!</p></font></td><tr>
<td width="200">

<font size="4">New motto:</p></font></td><td width="400">

<font size="4"><input type="text" size="50" maxlength="255" name="clan_motto"></p></font></td><tr>
<td width="200">
</td><td width="400">Leave blank for no new motto<input type="submit" value="Change">
</td>
</form>
<form action="clan.php?action=chage_admin" method="POST">
<input type="hidden" name="admin_pass" value="00000000">
<input type="hidden" name="clan_name" value="TS">
<td width="200">
</td><td width="400">
</td><tr>
alle "option name" sachen möcchte ich dort rauskopieren, ne ahnung wie ich das anstelle?

mirage228 25. Okt 2003 17:32

Re: String: Copy, Pos
 
also ich würde erst die positionen von "<select" und "</select>" herausfinden mit POS. Da sind dann alle Optionen drinne.

dann gehst du nach für nach jedes item durch (das machst du, in dem du ein bearbeites item von der "liste" aller items abschneidest) und suchst mit pos nach 'name="' und dahinter nach dem '">'dann hast du z.B. hehe</option>
davon schneidest du dann </option> ab und Voila, fertig ;-)


mfg
mirage228

Pseudemys Nelsoni 25. Okt 2003 17:33

Re: String: Copy, Pos
 
danke :)

Duffy 25. Okt 2003 17:35

Re: String: Copy, Pos
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo silent,
ich habe Dir mal ein Beipiel gemacht, ich glaube Du findest Dich selber zurecht.
bye

Pseudemys Nelsoni 25. Okt 2003 17:36

Re: String: Copy, Pos
 
danke, guck ich mir nach dem essen direkt an :)

Pseudemys Nelsoni 25. Okt 2003 18:42

Re: String: Copy, Pos
 
jo, dein project funzt einwandfrei :)


ich habe nochmal eine frage, und zwar...

das ist der original quelltext:

Zitat:

<html>

<head>

<title>CNC Reloaded - Battle Clans</title>

</head>

<body>

<center>

<h1>CNC:R Tiberian Sun Battle Clans</h1>

<h2>Text-Only version</h2>








<h3>Administrate Battle Clans</h3>

<table border="0" cellspacing="0" cellpadding="0">
<td width="200">

<font size="4">Clan name:</p></font></td><td width="400">

<font size="4">Best game ever</p></font></td><tr>
<td width="200">

<font size="4">Abbreviation:</p></font></td><td width="400">

<font size="4">TS</p></font></td><tr>
<td width="200">
</td><td width="400">
</td><tr>
<form action="clan.php?action=kick_member" method="POST">
<input type="hidden" name="admin_pass" value="00000000">
<input type="hidden" name="clan_name" value="TS">
<td width="200">

<font size="4">Kick member:</p></font></td><td width="400"><select name="kick_mem">

<option name="hehe">hehe</option>
<option name="haha">haha</option>
<option name="LooL">LooL</option>
<option name="keke">keke</option>
<option name="huhu">huhu</option>
<option name="lalilu">lalilu</option>
<option name="sudnevo">sudnevo</option>
<option name="heinz">heinz</option>
<option name="tcclanplz">tcclanplz</option>
<option name="uwe33">uwe33</option>

</select><input type="submit" value="Kick"></td></form>
<form action="clan.php?action=chage_motto" method="POST">
<input type="hidden" name="admin_pass" value="02580258">
<input type="hidden" name="clan_name" value="TS">
<td width="200">
</td><td width="400">
</td><tr>
<td width="200">

<font size="4">Motto:</p></font></td><td width="400">

<font size="4">TS!</p></font></td><tr>
<td width="200">

<font size="4">New motto:</p></font></td><td width="400">

<font size="4"><input type="text" size="50" maxlength="255" name="clan_motto"></p></font></td><tr>
<td width="200">
</td><td width="400">Leave blank for no new motto<input type="submit" value="Change">
</td>
</form>
<form action="clan.php?action=chage_admin" method="POST">
<input type="hidden" name="admin_pass" value="00000000">
<input type="hidden" name="clan_name" value="TS">
<td width="200">
</td><td width="400">
</td><tr>

nun möchte ich von "<select name="kick_mem">" bis "</select>" kopieren, dies mache ich mit:

Delphi-Quellcode:
procedure TForm2.Button3Click(Sender: TObject);
begin
  Memo1.Text := Copy(Memo1.Text, Pos('<select name="kick_mem">', Memo1.Text), Pos('</select>', memo1.Text));
end;
bei einem Klick auf den button sieht das memo dann so aus:

Zitat:

<select name="kick_mem">
<option name="hehe">hehe</option>
<option name="haha">haha</option>
<option name="LooL">LooL</option>
<option name="keke">keke</option>
<option name="huhu">huhu</option>
<option name="lalilu">lalilu</option>
<option name="sudnevo">sudnevo</option>
<option name="heinz">heinz</option>
<option name="tcclanplz">tcclanplz</option>
<option name="uwe33">uwe33</option>
</select><input type="submit" value="Kick"></td></form>
<form action="clan.php?action=chage_motto" method="POST">
<input type="hidden" name="admin_pass" value="02580258">
<input type="hidden" name="clan_name" value="TS">
<td width="200">
</td><td width="400">
</td><tr>
<td width="200">

<font size="4">Motto:</p></font></td><td width="400">

<font size="4">TS!</p></font></td><tr>
<td width="200">

<font size="4">New motto:</p></font></td><td width="400">

<font size="4"><input type="text" size="50" maxlength="255" name="clan_motto"></p></font></td><tr>
<td width="200">
</td><td width="400">Leave blank for no new motto<input type="submit" value="Change">
</td>
</form>
<form action="clan.php?action=chage_admin" method="POST">
<input type="hidden
bei einem zweitem klick so(wie es sein sollte):

Zitat:

<select name="kick_mem">
<option name="hehe">hehe</option>
<option name="haha">haha</option>
<option name="LooL">LooL</option>
<option name="keke">keke</option>
<option name="huhu">huhu</option>
<option name="lalilu">lalilu</option>
<option name="sudnevo">sudnevo</option>
<option name="heinz">heinz</option>
<option name="tcclanplz">tcclanplz</option>
<option name="uwe33">uwe33</option>
<
nun die frage, wieso muss ich 2mal klicken bis ich das so habe?

RomanK 25. Okt 2003 18:52

Re: String: Copy, Pos
 
Hoi silent,
der dritte Copy-Parameter gibt die Anzah der Zeichen an, die Kopiert werden sollen, nicht wie bei dir, die Stelle.


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:23 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz