Skip to content

Instantly share code, notes, and snippets.

@nagisa
Created November 9, 2012 11:19
Show Gist options
  • Save nagisa/4045210 to your computer and use it in GitHub Desktop.
Save nagisa/4045210 to your computer and use it in GitHub Desktop.

Pos(char what_to_find, string where_to_find)

Nustato char vietą string'e

Gražina integerį.

Program Example;
Var S : String;
begin
    S := 'The first space in this sentence is at position : ';
    Writeln(S, pos(' ', S));
    S := 'The last letter of the alphabet doesn''t appear in this sentence ';
    If(Pos('Z', S) = 0) and (Pos('z', S) = 0) then Writeln(S);
end.

Copy(string of, int from, int to)

Padaro string'o kopiją nuo ženklo numeris from iki ženklo numeris to.

Gražina string tipo kopiją.

NOTE: stringą galima saugiai keisti nekeičiant ankstesnio stringo.

Program Example;
Var S, T : String;
begin
    T := '1234567';
    S := Copy (T, 1, 2);   { S := '12' }
    S := Copy (T, 4, 2);   { S := '45' }
    S := Copy (T, 4, 8);   { S := '4567' }
end.

Delete(string your_string, int from, int to)

Ištrina visus ženklus nuo from iki to iš stringo your_string.

Program Example;
Var S : String;
begin
    S := 'This is not easy !';
    Delete (S, 9, 4); { S := 'This is easy !' }
end.

Negražina nieko.

Insert(string what_to_insert, string into_what_to_insert, int where_to_insert)

Įterpia what_to_insert į into_what_to_insert po where_to_insert pozicijos.

Negražina nieko.

Program Example;
Var S : String;
begin
    S := 'Free Pascal is difficult to use !';
    Insert('NOT ', S, pos('difficult', S));
    writeln(s);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment