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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b36dd33f588facee,start X-Google-Attributes: gid103376,public From: bumwad@my-deja.com Subject: gnat.spitbol.patterns.match(...) Date: 2000/10/05 Message-ID: <8rj38u$1d6$1@nnrp1.deja.com>#1/1 X-Deja-AN: 678079397 X-Http-Proxy: 1.0 x70.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Oct 05 23:06:21 2000 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0) Date: 2000-10-05T00:00:00+00:00 List-Id: I am trying to use gnat's Spitbol/pattern packages to create a string by removing a regexp from one and replacing it with another. for example I have a string "c:\a\b\c\d\foo" and path "c:\a\b\" and another path "c:\x\y\". I want to create "c:\x\y\c\d\foo". I am writing a unifying directory trees utility. env = Nt 4.0, gnat 3.13p here is code .... Base_Dir_from_Pattern : constant Gnat.Spitbol.Patterns.Pattern := Gnat.Spitbol.Patterns.Span("c:\testChamber\t99\"); ... Ada.TExt_Io.Put_Line("Subject = " & Ada.Strings.Unbounded.To_String (Curr_Dir_To_Name_Vstring)); Ada.TExt_Io.Put_Line("Pat = " & Gnat.Spitbol.Patterns.Image (Base_Dir_From_Pattern)); Ada.TExt_Io.Put_Line("Replace = " & Base_Dir_To); Replacement_Successful := Gnat.Spitbol.Patterns.Match (Subject => Curr_Dir_To_Name_Vstring, -- Gnat.Spitbol.Patterns.VString_Var Pat => Base_Dir_From_Pattern, -- pattern Replace => Base_Dir_To -- string ); ADA.Text_IO.NEW_LINE(2); Ada.TExt_Io.Put_Line("Subject = " & Ada.Strings.Unbounded.To_String (Curr_Dir_To_Name_Vstring)); Ada.TExt_Io.Put_Line("Pat = " & Gnat.Spitbol.Patterns.Image (Base_Dir_From_Pattern)); Ada.TExt_Io.Put_Line("Replace = " & Base_Dir_To); ADA.Text_IO.NEW_LINE(5); and output ( go through a loop with a recursive call and dir tree only 2 deep). See that the directory a_dir is missing the initial 'a' after the call on match() but not on a_dir_in_a_dir (!?) .... C:\testChamber>synchem3 Subject = c:\testChamber\t99\a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t100\_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t99 \a_dir\a_dir_in_a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Subject = c:\testChamber\t100 \_dir\a_dir_in_a_dir Pat = Span ("9:C\abcehmrst") Replace = c:\testChamber\t100\ Thanks, Keith Sent via Deja.com http://www.deja.com/ Before you buy.