[Pharo-project] how to simply double a ' inside string
comment copyReplaceAll: (String with: $') with: (String with: $' with: $'). Trying with 'ababc' .'a' . 'aa' . 'aabaabc' is way simpler than with $' Stef On May 3, 2010, at 10:48 PM, Stéphane Ducasse wrote:
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Stef, First, try #printString - it might do the job for you. Failing that, you can do something like | out | out := WriteStream on:String new. self do:[ :c | c = $' ifTrue:[ out nextPut:$' ]. out nextPut:c. ]. ^out contents. I'll be interested to see all of the better ways to do this. Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Monday, May 03, 2010 3:48 PM To: Pharo Development Subject: [Pharo-project] how to simply double a ' inside string Does anybody know how to double a ' inside a string? Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
s := ''''''. s size -> 2 works fine for me. am i missing something? - on On May 3, 2010, at 22:54 , Schwab,Wilhelm K wrote:
Stef,
First, try #printString - it might do the job for you. Failing that, you can do something like
| out | out := WriteStream on:String new. self do:[ :c | c = $' ifTrue:[ out nextPut:$' ]. out nextPut:c. ]. ^out contents.
I'll be interested to see all of the better ways to do this.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Monday, May 03, 2010 3:48 PM To: Pharo Development Subject: [Pharo-project] how to simply double a ' inside string
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Oscar, you should think of the question as: "what is the simplest piece of code that could take your string ('''''', which has two quotes in it) and return a new one with four quotes in it instead of two?" -- Cheers, Peter On Tue, May 4, 2010 at 10:33 AM, Oscar Nierstrasz <oscar@iam.unibe.ch>wrote:
s := ''''''. s size -> 2
works fine for me. am i missing something?
- on
On May 3, 2010, at 22:54 , Schwab,Wilhelm K wrote:
Stef,
First, try #printString - it might do the job for you. Failing that, you can do something like
| out | out := WriteStream on:String new. self do:[ :c | c = $' ifTrue:[ out nextPut:$' ]. out nextPut:c. ]. ^out contents.
I'll be interested to see all of the better ways to do this.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto: pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Monday, May 03, 2010 3:48 PM To: Pharo Development Subject: [Pharo-project] how to simply double a ' inside string
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Ah! Now, I get it. What about this? '''''' join: ('''' split: 'don''t') -> 'don''''t' Not as efficient as using a stream, but pretty simple. - on On May 4, 2010, at 10:54 , Peter Hugosson-Miller wrote:
Oscar, you should think of the question as: "what is the simplest piece of code that could take your string ('''''', which has two quotes in it) and return a new one with four quotes in it instead of two?"
-- Cheers, Peter
On Tue, May 4, 2010 at 10:33 AM, Oscar Nierstrasz <oscar@iam.unibe.ch> wrote:
s := ''''''. s size -> 2
works fine for me. am i missing something?
- on
On May 3, 2010, at 22:54 , Schwab,Wilhelm K wrote:
Stef,
First, try #printString - it might do the job for you. Failing that, you can do something like
| out | out := WriteStream on:String new. self do:[ :c | c = $' ifTrue:[ out nextPut:$' ]. out nextPut:c. ]. ^out contents.
I'll be interested to see all of the better ways to do this.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Monday, May 03, 2010 3:48 PM To: Pharo Development Subject: [Pharo-project] how to simply double a ' inside string
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Nice! :-D Follows the KISS principle perfectly! -- Cheers, Peter On Tue, May 4, 2010 at 12:08 PM, Oscar Nierstrasz <oscar@iam.unibe.ch>wrote:
Ah! Now, I get it.
What about this?
'''''' join: ('''' split: 'don''t') -> 'don''''t'
Not as efficient as using a stream, but pretty simple.
- on
On May 4, 2010, at 10:54 , Peter Hugosson-Miller wrote:
Oscar, you should think of the question as: "what is the simplest piece of code that could take your string ('''''', which has two quotes in it) and return a new one with four quotes in it instead of two?"
-- Cheers, Peter
On Tue, May 4, 2010 at 10:33 AM, Oscar Nierstrasz <oscar@iam.unibe.ch> wrote:
s := ''''''. s size -> 2
works fine for me. am i missing something?
- on
On May 3, 2010, at 22:54 , Schwab,Wilhelm K wrote:
Stef,
First, try #printString - it might do the job for you. Failing that, you can do something like
| out | out := WriteStream on:String new. self do:[ :c | c = $' ifTrue:[ out nextPut:$' ]. out nextPut:c. ]. ^out contents.
I'll be interested to see all of the better ways to do this.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto: pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Stéphane Ducasse Sent: Monday, May 03, 2010 3:48 PM To: Pharo Development Subject: [Pharo-project] how to simply double a ' inside string
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
'don''t' printString withoutQuoting Regards, Gary ----- Original Message ----- From: "Stéphane Ducasse" <Stephane.Ducasse@inria.fr> To: "Pharo Development" <Pharo-project@lists.gforge.inria.fr> Sent: Monday, May 03, 2010 9:48 PM Subject: [Pharo-project] how to simply double a ' inside string
Does anybody know how to double a ' inside a string?
Stef
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
participants (6)
-
Gary Chambers -
Oscar Nierstrasz -
Peter Hugosson-Miller -
Schwab,Wilhelm K -
Stéphane Ducasse -
Stéphane Ducasse