Well the problem is that the string I want to replace will usually be in the middle of a line in the text file and then is PrefixOf of no use?? Any other suggestion??
Like the text file will be similar to abcdedjkfhlafl sajkhlabbbbsf akfhjklafjkhfk sdfasfsaasffaa So I want to replace this bbbb in the middle there with aaaa. I could run lines on the file but from there i have no idea. I have got an idea but for it to work I need to know if there is a function that I can replace a certain Char in a string by another Char by knowing the index of this char?? Best Regards NooK ----- Original Message ----- From: "Hal Daume III" <[EMAIL PROTECTED]> To: "Alexandre Weffort Thenorio" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, March 13, 2003 1:05 AM Subject: Re: How to search for a string sequence in a file a rewrite it??? > This is how I would do it: > > recurse down the input string. use isPrefixOf to check is the string youw > ant to replace is at the head of the string. if it is, 'drop' the > appropriate number of characters and stick the replacement string on the > front. then recurse. > > this should be about 3 lines of code. > > -- > Hal Daume III | [EMAIL PROTECTED] > "Arrest this man, he talks in maths." | www.isi.edu/~hdaume > > On Thu, 13 Mar 2003, Alexandre Weffort Thenorio wrote: > > > OK Guys. First I would like to say thanks for all the help given before. As > > I said I am still learning Haskell. My problem is the following: > > > > I have a text file and somewhere in the file there is string (Let's say > > aaaa). So I need to find this exact string and overwrite with another string > > (Lets say bbbb). > > > > I have thought a bit and couldn't find any solution, and I believe it is a > > piece of cake for some of you. Is there a method already implemented in > > haskell to do that?? > > Anyway thanks in advance. > > > > Best Regards > > > > NooK > > > > ----- Original Message ----- > > From: "Arthur Baars" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Cc: "Norman Ramsey" <[EMAIL PROTECTED]> > > Sent: Wednesday, March 12, 2003 1:06 AM > > Subject: Re: clueless GHCI user wishes to load QuickCheck > > > > > > > QuickCheck is in de "util" package. You can load a package with the > > > -package flag: > > > > > > $ ghci -package util > > > Prelude> :browse QuickCheck > > > class Arbitrary a where { > > > arbitrary :: Gen a; coarbitrary :: forall b. a -> Gen b -> Gen b; } > > > arbitrary :: forall a. (Arbitrary a) => Gen a > > > ... > > > Prelude>:module QuickCheck > > > > > > Prelude QuickCheck> :info trivial > > > -- trivial is a variable > > > trivial :: forall a. (Testable a) => Bool -> a -> Property > > > > > > Hope this helps. > > > > > > Cheers, > > > > > > Arthur > > > > > > On Tuesday, March 11, 2003, at 07:02 PM, Norman Ramsey wrote: > > > > > > > Can anyone help me figure out how to load QuickCheck into GHCI? > > > > QuickCheck is included in my Debian package, but my attempts > > > > at loading it are bootless: > > > > > > > > Prelude> :load QuickCheck > > > > can't find module `QuickCheck' > > > > Prelude> :load util/QuickCheck > > > > can't find module `util/QuickCheck' > > > > Prelude> :info > > > > syntax: `:i <thing-you-want-info-about>' > > > > Prelude> :load util/QuickCheck.hi > > > > can't find module `util/QuickCheck.hi' > > > > Prelude> :load /usr/lib/ghc-5.02.2/imports/util/QuickCheck.hi > > > > can't find module `/usr/lib/ghc-5.02.2/imports/util/QuickCheck.hi' > > > > Prelude> :load /usr/lib/ghc-5.02.2/imports/util/QuickCheck > > > > can't find module `/usr/lib/ghc-5.02.2/imports/util/QuickCheck' > > > > Prelude> > > > > > > > > Any advice, anyone? > > > > > > > > > > > > Norman > > > > _______________________________________________ > > > > Haskell mailing list > > > > [EMAIL PROTECTED] > > > > http://www.haskell.org/mailman/listinfo/haskell > > > > > > > > > > _______________________________________________ > > > Haskell mailing list > > > [EMAIL PROTECTED] > > > http://www.haskell.org/mailman/listinfo/haskell > > > > > > > _______________________________________________ > > Haskell mailing list > > [EMAIL PROTECTED] > > http://www.haskell.org/mailman/listinfo/haskell > > > > _______________________________________________ > Haskell mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell > _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell