From: bumwad@my-deja.com
Subject: gnat.spitbol.patterns.match(...)
Date: 2000/10/05
Date: 2000-10-05T00:00:00+00:00 [thread overview]
Message-ID: <8rj38u$1d6$1@nnrp1.deja.com> (raw)
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.
next reply other threads:[~2000-10-05 0:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-05 0:00 bumwad [this message]
2000-10-06 0:42 ` gnat.spitbol.patterns.match(...) dale
2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar
2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Dale Stanbrough
2000-10-07 0:25 ` gnat.spitbol.patterns.match(...) Ted Dennison
2000-10-06 3:14 ` gnat.spitbol.patterns.match(...) Ted Dennison
2000-10-06 0:00 ` gnat.spitbol.patterns.match(...) Robert Dewar
2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus
2000-10-07 0:00 ` gnat.spitbol.patterns.match(...) Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox