[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

sprintf percent sign problem

mpthimios

11/4/2007 8:38:00 AM

Hi,
I am trying to format some text using sprintf. The text itself
contains the percent sign (%).

When I use it without any escape character, as expected ruby throws
error (unkonown format sequence).

When I use the "\%" sequence ruby complaints when the "\%" is
somewhere in the text. When it is at the end it works but I don't want
it there.

When I use the "%%" sequence, I get the exact sequence as output ("%%"
is printed!!)..
Has anyone observed this behavior? Am I doing something wrong or it is
a ruby bug?

Thanks in advance,
Efthimios.

25 Answers

7stud --

11/4/2007 9:08:00 AM

0

Efthimios Bothos wrote:
> Hi,
> I am trying to format some text using sprintf. The text itself
> contains the percent sign (%).
>
> When I use it without any escape character, as expected ruby throws
> error (unkonown format sequence).
>

I'm not seeing that:

str = "hello%world"
new_str = sprintf('%20s', str)
puts new_str

--output:--
hello%world


It's always baffling to me why a poster doesn't just post a simplified
example along with the error.
--
Posted via http://www.ruby-....

Giles Bowkett

11/4/2007 7:15:00 PM

0

> It's always baffling to me why a poster doesn't just post a simplified
> example along with the error.

If they knew to provide tests, they wouldn't be asking syntax
questions in the first place. That's an experienced programmer's rule,
and syntax questions usually come from newbies.

It is a very good idea to provide test cases in responses, though.
Apart from anything else, whenever I do that I go into IRB and half
the time find out something more interesting than whatever I was going
to say.

--
Giles Bowkett

Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles.t...

Carolina Reb

2/26/2012 11:35:00 AM

0


"The Revd" <peeling@degenerate.Grik> wrote in message
news:805kk7ldlo5vp3t3bgmaehpij76t33gjki@4ax.com...
>>
>>Meanwhile, Whitney Houston has been sober for 7 days! You go girl!!!
>
> Another useless nigger gone.

No doubt she will remain sober for another seven days :-)


The Peeler

2/26/2012 11:39:00 AM

0

On Sun, 26 Feb 2012 06:35:01 -0500, Caroloony Reb, the subnormal moron and
attested schizo from the States, wrote:


>>>Meanwhile, Whitney Houston has been sober for 7 days! You go girl!!!
>>
>> Another useless nigger gone.
>
> No doubt she will remain sober for another seven days :-)

Will she, you hilarious, stupid, fucked up schizo? LOL

--
DoD about our resident schizo:
"You have nothing better to do with your time than mouthing off on usenet on
what you would like to do with people you don't even know and spew bigotry."
MID: <132d2742-c469-40ec-a189-14362512151d@f30g2000yqh.googlegroups.com>

Carolina Reb

2/26/2012 11:42:00 AM

0


"The Peeler" <slapping@themoronicRevd.invalid> wrote in message
news:4f4a19cd$1@news.x-privat.org...
> >>
>> No doubt she will remain sober for another seven days :-)
>
> Will she,

Why don't you dig her dead ass up and check for yourself, you delusional
Kike....


The Peeler

2/26/2012 11:51:00 AM

0

On Sun, 26 Feb 2012 06:42:04 -0500, Caroloony Reb, the subnormal moron and
attested schizo from the States, wrote:

>>> No doubt she will remain sober for another seven days :-)
>>
>> Will she, you hilarious, stupid, fucked up schizo? LOL
>
> Why don't you dig her dead ass up and check for yourself, you delusional
> Kike....

LMAO!!!!! Like I said: you are a hilarious, stupid, fucked up schizo!

Looking forward towards your next display of your schizophrenia! <G>

The Revd

2/26/2012 11:55:00 AM

0

On Sun, 26 Feb 2012 06:35:01 -0500, "Carolina Reb"
<walt.hampton@att.net> wrote:

>
>"The Revd" <peeling@degenerate.Grik> wrote in message
>news:805kk7ldlo5vp3t3bgmaehpij76t33gjki@4ax.com...
>>>
>>>Meanwhile, Whitney Houston has been sober for 7 days! You go girl!!!
>>
>> Another useless nigger gone.
>
>No doubt she will remain sober for another seven days :-)

No need to embalm....she's already marinated!

Carolina Reb

2/26/2012 12:03:00 PM

0


"The Revd" <peeling@degenerate.Grik> wrote in message
news:0c7kk75lvsctt063itgfajtchqv5fejn9g@4ax.com...
> >
> No need to embalm....she's already marinated!

No doubt she was holocausted by Jack Daniels!


The Peeler

2/26/2012 12:07:00 PM

0

On Sun, 26 Feb 2012 07:03:10 -0500, Caroloony Reb, the subnormal moron and
attested schizo from the States, wrote:


>> No need to embalm....she's already marinated!
>
> No doubt she was holocausted by Jack Daniels!

Was she, you hilarious, stupid, fucked up schizo? LMAO! Tell us more about
that!

--
DoD about our resident schizo:
"You have nothing better to do with your time than mouthing off on usenet on
what you would like to do with people you don't even know and spew bigotry."
MID: <132d2742-c469-40ec-a189-14362512151d@f30g2000yqh.googlegroups.com>

Carolina Reb

2/26/2012 12:15:00 PM

0


"The Peeler" <slapping@themoronicRevd.invalid> wrote in message
news:4f4a204a$1@news.x-privat.org...
>>
> Our
> BUAHAHAHAHAHAAAAAAA!!!!

There there now....try to get a grip. This is only Usenet.