简体   繁体   English

如何从字符串开头到字符串结尾复制4个字符?

[英]How can copy 4 character from begining of string to end of string?

For example: 例如:

var
s:string;
begin
s:='Hello1234567';

end;
end.

How can I copy from string 4 byte 4 byte..Example showmessage('hell') and showmessage('o123') and showmessage('4567')? 如何从字符串4字节4字节中复制..例如showmessage('hell')和showmessage('o123')和showmessage('4567')?

Use the Copy() function for that: 为此使用Copy()函数:

var
  s: string;
begin
  s := 'Hello1234567';
  ShowMessage(Copy(s, 1, 4));
  ShowMessage(Copy(s, 5, 4));
  ShowMessage(Copy(s, 9, 4));
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM