|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Duplicate post. See here:
http://www.ruby-forum.com/topic/130350#new -- Posted via http://www.ruby-forum.com/. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
mpthimios 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). > > 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? I don't see that: irb(main):001:0> text = "foo%%bar" => "foo%%bar" irb(main):002:0> sprintf(text) => "foo%bar" -- Alex |
|
![]() |
| Outils de la discussion | |
|
|