From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,789b3fa522bdcc2a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-04 09:44:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Optimising string handling in application References: <1049451208.932382@edh3> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1049478237 12.234.13.56 (Fri, 04 Apr 2003 17:43:57 GMT) NNTP-Posting-Date: Fri, 04 Apr 2003 17:43:57 GMT Organization: AT&T Broadband Date: Fri, 04 Apr 2003 17:43:57 GMT Xref: archiver1.google.com comp.lang.ada:35934 Date: 2003-04-04T17:43:57+00:00 List-Id: > However, sometimes I miss the expressionness of perl: > > s/([^;]*;ME001=)([^;]*)(;[^;]*)/$1$callsign$3/; What does that do if "ME001=" or the ';' aren't present? What does "expressionness" mean? Does: function Replace_Callsign_In_Message(M, C : String) return String is use Ada.Strings.Fixed; Eq : constant Positive := Index(M, "ME001=")+5; begin return M(M'first .. Eq) & C & M(Index(M(Eq .. M'last),";') .. M'last); end Replace_Callsign_In_Message; have more or less of it than: function Replace_Callsign_In_Message(Msg, New_Callsign : String) return String is use Ada.Strings.Fixed; Eq : constant Positive := Index(Msg, "ME001=")+5; Semi : Natural; begin if Eq = 5 then raise Constraint_Error;end if; -- missing "ME001=" Semi := Index(Msg, ";"); if Semi = 0 then raise Constraint_Error;end if; -- missing ";" return Msg(Msg'first .. Eq) & New_Callsign & Msg(Semi .. Msg'last); end Replace_Callsign_In_Message;