我在重新索引切片字符串时遇到问题,
procedure String_Test is
mystr:String:="Hello World";
str:String:=mystr(6 .. 11);
str_re_indexed:String:=Trim(Str, Left); -- it works but whitespace is removed
begin
for K in str_re_indexed'First .. str_re_indexed'Last loop
Put_Line(Integer'Image(K));
end loop;
end String_Test;
重新索引后,字符串应为 (1 ..6)
有没有预定义的函数可以做到这一点?
您可以为此定义一个字符串子类型:
subtype String_1_6 is String (1 .. 6);
Result : String := String_1_6 (My_Str);