Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi how to split string? (https://www.delphipraxis.net/68849-how-split-string.html)

alpha1 6. Mai 2006 16:13


how to split string?
 
Hi!
Here is my question: I have this string line:" Google search=http://www.google.com " or this:" Yahoo page=http://www.yahoo.com " (symbols "=" and "http" are in everywhere line). I need to split string line to get this: One string - "Google search" and other string - "http://www.google.com".
Please help me :wink: :!:
Thank`s!

Dax 6. Mai 2006 16:16

Re: how to split string?
 
Hey there, how about that?

Delphi-Quellcode:
ItemName := Copy(ItemString, 1, Pos('=', ItemString)-1);
ItemURL := Copy(ItemString, Pos('=', ItemString)+1, Length(ItemString));
Should work :)

edit: oh darn, forgot the ':'s :mrgreen:

Muetze1 6. Mai 2006 16:23

Re: how to split string?
 
Another possibility is the usage of the Values[] and Names[] properties of a TString descendant (e.g. TStringList).

alpha1 6. Mai 2006 16:53

Re: how to split string?
 
Thank`s! It works great!

alpha1 9. Mai 2006 16:08

Re: how to split string?
 
Hello again! :-D
I have one new question: I have ini file with section "favorites", wherein are many lines like this one: "Google search=http://www.google.com". I need to add this section to the ListBox1, but there must be only names ("Google search") and on click this name webbrowser must to navigate "http://www.google.com" (program must to remember name`s url).

Matze 9. Mai 2006 16:14

Re: how to split string?
 
Hello

Zitat:

Zitat von alpha1
I have one new question [..]

Please create a new thread for each question. The reason is that it's easier to find a solution for a ploblem with the search function when only one question is asked in one thread. Thank you. ;)

marabu 9. Mai 2006 16:24

Re: how to split string?
 
Hello alpha1,

mind your wording. This seems to be more of a zoom-in question. Make sure you use TMemIniFile instead of TIniFile. Read the Names from your link section using the method ReadSection(). Once an item is clicked you can fetch the hyperlink on-demand by using ReadString().

Regards, marabu


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:12 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