Como transformo uma String em um conjunto ?
tipo
axSTR := ´1,2,3´
if 1 in axSTR then
como se fosse : if 1 in [1,2,3] then
axSTR := ´1,2,3´
if 1 in axSTR then
como se fosse : if 1 in [1,2,3] then
Programadorjlle
Curtidas 0
Respostas
Nildo
09/02/2005
tipo
axSTR := ´1,2,3´
if 1 in axSTR then
como se fosse : if 1 in [1,2,3] then
Transforme axSTR em ´1,2,3[b:165bf4be1e],[/b:165bf4be1e]´ (com a vírgula no final)
e use:
if pos( ´1,´, axSTR ) <> 0 then ShowMessage( ´Existe´ );
ou então
if pos( inttostr( 1 ) + ´,´, axSTR ) <> 0 then ShowMessage( ´Existe´ );
Espero ter ajudado
GOSTEI 0
Programadorjlle
09/02/2005
mas nao posso usar o POS pq se tiver assim [´1´] ai ele nao acha
nao tem como coverter a string em um conjunto ?
Transforme axSTR em ´1,2,3[b:f2688e262a],[/b:f2688e262a]´ (com a vírgula no final)
e use:
ou então
Espero ter ajudado[/quote:f2688e262a]
nao tem como coverter a string em um conjunto ?
[quote:f2688e262a=´programadorjlle´]tipo
axSTR := ´1,2,3´
if 1 in axSTR then
como se fosse : if 1 in [1,2,3] then
Transforme axSTR em ´1,2,3[b:f2688e262a],[/b:f2688e262a]´ (com a vírgula no final)
e use:
if pos( ´1,´, axSTR ) <> 0 then ShowMessage( ´Existe´ );
ou então
if pos( inttostr( 1 ) + ´,´, axSTR ) <> 0 then ShowMessage( ´Existe´ );
Espero ter ajudado[/quote:f2688e262a]
GOSTEI 0
Nildo
09/02/2005
mas entao é só não usar [´1´], é só usar do jeito que eu falei, e trocar o IN pelo POS
GOSTEI 0
Briciosm
09/02/2005
Não sei se entendi?
Mas acho que é isso...
variavelstring:=´texto 12343455...´
//ver se existe a substring na string
if pos(´1´,variavelstring)<>0 then
begin
//inserir substring na string
insert(´xxx´,variavelstring,pos(´1´,variavelstring)-1);
end;
Mas acho que é isso...
variavelstring:=´texto 12343455...´
//ver se existe a substring na string
if pos(´1´,variavelstring)<>0 then
begin
//inserir substring na string
insert(´xxx´,variavelstring,pos(´1´,variavelstring)-1);
end;
GOSTEI 0
Marcelo Saviski
09/02/2005
Converter String em conjunto, poderia ser assim:
var Texto: string; Conjunto: TSysCharSet; I: Integer; begin Texto := ´123´; Conjunto := []; for I := 1 to Length(Texto) do Include(Conjunto, Texto[I]); //Agora vc vai ter um Conjunto de caracteres //Conjunto = [´1´, ´2´, ´3´] end;
GOSTEI 0
Aroldo Zanela
09/02/2005
Colega,
A forma de menor esforço é utilizando a classe TStringList.
A forma de menor esforço é utilizando a classe TStringList.
GOSTEI 0
Nildo
09/02/2005
[quote:271c1a27ff=´Aroldo Zanela´]Colega,
A forma de menor esforço é utilizando a classe TStringList.[/quote:271c1a27ff]
Eu, particularmente, evito usar classes onde métodos/propriedades ocupam espaço a toa na memória. Ele não usaria todos os recursos da TStringList... bom, mas se velocidade/memória não forem o problema, é a forma mais facil mesmo.
A forma de menor esforço é utilizando a classe TStringList.[/quote:271c1a27ff]
Eu, particularmente, evito usar classes onde métodos/propriedades ocupam espaço a toa na memória. Ele não usaria todos os recursos da TStringList... bom, mas se velocidade/memória não forem o problema, é a forma mais facil mesmo.
GOSTEI 0