comp.lang.ada
 help / color / mirror / Atom feed
* gnat.spitbol.patterns.match(...)
@ 2000-10-05  0:00 bumwad
  2000-10-06  0:42 ` gnat.spitbol.patterns.match(...) dale
  0 siblings, 1 reply; 9+ messages in thread
From: bumwad @ 2000-10-05  0:00 UTC (permalink / 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.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2000-10-07  0:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-05  0:00 gnat.spitbol.patterns.match(...) bumwad
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox