From: Neil Jerram <neil@ossau.uklinux.net>
To: Sebastian Tennant <sebyte@smolny.plus.com>
Cc: guile-user@gnu.org
Subject: Re: Replacing substrings in strings
Date: Sat, 02 May 2009 01:29:57 +0100 [thread overview]
Message-ID: <87presgxdm.fsf@arudy.ossau.uklinux.net> (raw)
In-Reply-To: <skkae6tk.fsf@vps203.linuxvps.org> (Sebastian Tennant's message of "Wed\, 15 Apr 2009 07\:04\:23 +0000")
Sebastian Tennant <sebyte@smolny.plus.com> writes:
> Quoth Linas Vepstas <linasvepstas@gmail.com>:
>> 2009/4/14 Sebastian Tennant <sebyte@smolny.plus.com>:
>>> I needed to replace two consecutive spaces in strings with ' ' so
>>
>> Most programming languages use regex, and so does guile:
>
> Of course it can be done using regexps, I'm just a little surprised
> there isn't already a replace-substring function knocking around.
There is, and I guess it's what Linas had in mind:
regexp-substitute/global (from (ice-9 regex)).
For example:
;; Replace forward slashes by backward ones.
(set! path (regexp-substitute/global #f "/" path 'pre "\\" 'post))
Regards,
Neil
next prev parent reply other threads:[~2009-05-02 0:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 17:18 Replacing substrings in strings Sebastian Tennant
2009-04-14 17:35 ` Linas Vepstas
2009-04-15 7:04 ` Sebastian Tennant
2009-05-02 0:29 ` Neil Jerram [this message]
2009-04-15 8:52 ` Ludovic Courtès
2009-04-15 9:09 ` Sebastian Tennant
2009-04-15 14:32 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87presgxdm.fsf@arudy.ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
--cc=guile-user@gnu.org \
--cc=sebyte@smolny.plus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).