how to simply double a ' inside string

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

how to simply double a ' inside string

Stéphane Ducasse
Does anybody know how to double a ' inside a string?

Stef

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Stéphane Ducasse
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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Schwab,Wilhelm K
In reply to this post by Stéphane Ducasse
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: [hidden email] [mailto:[hidden email]] 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
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Oscar Nierstrasz

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: [hidden email] [mailto:[hidden email]] 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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Peter Hugosson-Miller
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 <[hidden email]> 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: [hidden email] [mailto:[hidden email]] 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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project




_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Oscar Nierstrasz

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 <[hidden email]> 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: [hidden email] [mailto:[hidden email]] 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
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Peter Hugosson-Miller
Nice! :-D Follows the KISS principle perfectly!

-- 
Cheers,
Peter

On Tue, May 4, 2010 at 12:08 PM, Oscar Nierstrasz <[hidden email]> 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 <[hidden email]> 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: [hidden email] [mailto:[hidden email]] 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
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Gary Chambers-4
In reply to this post by Stéphane Ducasse
'don''t' printString withoutQuoting

Regards, Gary

----- Original Message -----
From: "Stéphane Ducasse" <[hidden email]>
To: "Pharo Development" <[hidden email]>
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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project 


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: how to simply double a ' inside string

Stéphane Ducasse
cool!

Stef

On May 4, 2010, at 4:20 PM, Gary Chambers wrote:

> 'don''t' printString withoutQuoting


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project