Replace_Slice

Explicación

Replace_Slice reemplaza una subristra de Source. Para utilizarla hay que incluir la librería Ada.Strings.Bounded.

Sintaxis

function Replace_Slice (Source : in Bounded_String;
                        Low    : in Positive;
                        High   : in Natural;
                        By     : in String;
                        Drop   : in Truncation := Error)
  return Bounded_String;

procedure Replace_Slice (Source  : in out Bounded_String;
                         Low     : in Positive;
                         High    : in Natural;
                         By      : in String;
                         Drop    : in Truncation := Error);

Ejemplo

with Ada.Strings;           use Ada.Strings
with Ada.Strings.Bounded;   --  Librería de ristras de tamaño limitado
...
package Str100 is new Ada.Strings.Bounded.Generic_Bounded_Length(100); use Str100;  
...
SL: Str100.Bounded_String;
...

SL := To_Bounded_String ("Pedro corre");
SL := Replace_Slice (SL , 1, 5, "Jesús");  --  SL = "Jesús corre"
Replace_Slice (SL , 1, 5, "Santiago");     --  SL = "Santiago corre"
Créditos