Re: Replacing subsequences

From: Jeff (massung_at_gmail.com)
Date: 12/11/04


Date: Sat, 11 Dec 2004 02:54:18 GMT

Chris Capel wrote:

> I had a need just now to replace one substring in my string with a
> different substring, of a different length

If you want something that's quick to just "drop in and use", might I
suggest using my regular expression package (url below). It allows very
quick and simple replacing of text in a string:

(re:replace-all "Some random string"
                #/\s(\a+)$/
                (format nil "~D" (length $1)))

 ==> "Some random 6"

-- 
http://www.retrobyte.org
mailto:massung@gmail.com


Relevant Pages

  • Re: Computability and logic
    ... as regards a mathematical formulation of a substring ... substring in a string with another substring? ... result of substituting a term for a variable in a formula'. ... As I recall, he doesn't get into replacing term for term, ...
    (sci.logic)
  • Re: Replacing subsequences
    ... Chris Capel wrote: ... > I had a need just now to replace one substring in my string with a different ... > substring, of a different length (for quoting parameters to SQL queries, ...
    (comp.lang.lisp)
  • Re: Replacing subsequences
    ... Chris Capel writes: ... > I had a need just now to replace one substring in my string with a different ... If I need to do something like that, I usually end up using a string ... through the string, but if cases where no substitution is needed, it can ...
    (comp.lang.lisp)
  • Re: Looking For An Example Of Replacing Only One Occurrence In A String
    ... Robert Johnson wrote: ... > Does anyone have an example of replacing only one occurrence of a ... > substring in a string. ... > occurrences of the new string in the string. ...
    (microsoft.public.dotnet.framework)
  • Looking For An Example Of Replacing Only One Occurrence In A String
    ... Does anyone have an example of replacing only one occurrence of a ... substring in a string. ... occurrences of the new string in the string. ...
    (microsoft.public.dotnet.framework)