unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* is there any string-replace procedure in GUILE?
@ 2002-11-29 11:36 Veerapuram Varadhan
  2002-11-29 12:39 ` MJ Ray
       [not found] ` <87y97c4ea6.fsf@blarg.net>
  0 siblings, 2 replies; 5+ messages in thread
From: Veerapuram Varadhan @ 2002-11-29 11:36 UTC (permalink / raw)


Hi All,

I just want to know whether there is any string-replace procedure
available in guile like this...

(string-replace "GNU/Linux" "Linux" "Hurd") ?

or any equivalent with regex??

TIA,

Best Regards,

V. Varadhan.


-- 
Veerapuram Varadhan,
Systems Engineer,
CDC Linux,
Bangalore - 68.
Ph- (080)-5502999





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: is there any string-replace procedure in GUILE?
  2002-11-29 11:36 is there any string-replace procedure in GUILE? Veerapuram Varadhan
@ 2002-11-29 12:39 ` MJ Ray
  2002-11-29 13:24   ` Veerapuram Varadhan
       [not found] ` <87y97c4ea6.fsf@blarg.net>
  1 sibling, 1 reply; 5+ messages in thread
From: MJ Ray @ 2002-11-29 12:39 UTC (permalink / raw)


Veerapuram Varadhan <v.varadhan@cdclinux.com> wrote:
> I just want to know whether there is any string-replace procedure
> available in guile like this...

Do you want regexp-substitute?  Or, if you want to be portable, I expect
someone probably has a pregexp module for guile.

MJR



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: is there any string-replace procedure in GUILE?
  2002-11-29 12:39 ` MJ Ray
@ 2002-11-29 13:24   ` Veerapuram Varadhan
  0 siblings, 0 replies; 5+ messages in thread
From: Veerapuram Varadhan @ 2002-11-29 13:24 UTC (permalink / raw)


Hi Ray,

I have written one small module that does both version of string-replace.
:).  I just wanted to know whether i can post it to the guile list for the
use of others.

Anyway thanks for your response,

V. Varadhan.

> Veerapuram Varadhan <v.varadhan@cdclinux.com> wrote:
>> I just want to know whether there is any string-replace procedure
>> available in guile like this...
>
> Do you want regexp-substitute?  Or, if you want to be portable, I expect
> someone probably has a pregexp module for guile.
>
> MJR
>
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: is there any string-replace procedure in GUILE?
       [not found] ` <87y97c4ea6.fsf@blarg.net>
@ 2002-11-29 17:03   ` Veerapuram Varadhan
  2002-11-29 18:59     ` Thien-Thi Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Veerapuram Varadhan @ 2002-11-29 17:03 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

See the attached file Eric... it might help you... :)

>>>>>> "VV" == Veerapuram Varadhan <v.varadhan@cdclinux.com> writes:
>
>     VV> is there any string-replace procedure available in guile like
> VV> this...
>
>     VV> (string-replace "GNU/Linux" "Linux" "Hurd") ?
>
>     VV> or any equivalent with regex??
>
> `regexp-substitute/global' could probably be made to do that, but I
> couldn't figure out how.
>
> --
> PGP Fingerprint: 3E7B A3F3 96CA 8958 ACC5  C8BD 6337 0041 C01C 5276


-- 
Veerapuram Varadhan,
Systems Engineer,
CDC Linux,
Bangalore - 68.
Ph- (080)-5502999



[-- Attachment #2: string-replace-regex.scm --]
[-- Type: application/octet-stream, Size: 1351 bytes --]

#!/usr/bin/guile \
-s
!#
;;; string-replace-regex.scm: sample scheme program to demonstrate 
;;; regexp-substitute/global.
;;; author: V.Varadhan  <v.varadhan@cdclinux.com>

;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 2, or (at
;;; your option) any later version.
;;; 
;;; This program is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;; 
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
;;; 


(define (string-replace-regex source-string string-pattern replace-string)
  (let ((reg-ex (make-regexp string-pattern)))
    (if (and (string? source-string) (string? string-pattern) (string? replace-string))
	(regexp-substitute/global #f reg-ex source-string 'pre replace-string 'post)
	#f)))

(define source-str "GNU/Linux")
(define pattern-str "Linux")
(define replace-str "Hurd")
(display (string-replace-regex source-str pattern-str replace-str)) (newline)
;; GNU/Hurd

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

* Re: is there any string-replace procedure in GUILE?
  2002-11-29 17:03   ` Veerapuram Varadhan
@ 2002-11-29 18:59     ` Thien-Thi Nguyen
  0 siblings, 0 replies; 5+ messages in thread
From: Thien-Thi Nguyen @ 2002-11-29 18:59 UTC (permalink / raw)
  Cc: guile-user

    (if (and (string? source-string) [likewise other args])
	[substitution]
	#f)

probably you want to fail noisily rather than quietly.

thi


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2002-11-29 18:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-29 11:36 is there any string-replace procedure in GUILE? Veerapuram Varadhan
2002-11-29 12:39 ` MJ Ray
2002-11-29 13:24   ` Veerapuram Varadhan
     [not found] ` <87y97c4ea6.fsf@blarg.net>
2002-11-29 17:03   ` Veerapuram Varadhan
2002-11-29 18:59     ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).