From: Pen Ttt on
irb(main):001:0> "-34\n \302\240".match(/\S+/).to_s
=> "-34"
irb(main):002:0> "-\n \302\240".match(/\S+/).to_s
=> "-"
irb(main):003:0> "-?\n \302\240".match(/\S+/).to_s
=> "-?"
irb(main):004:0> "-jkl?\n \302\240".match(/\S+/).to_s
=> "-jkl?"
irb(main):005:0>

match(/\S+/).to_s is what i want.
--
Posted via http://www.ruby-forum.com/.

From: Pen Ttt on
if i want to convert
"-34\n \302\240" into "-34\n "
"-34jkl\n \302\240" into "-34jkl\n "
"-34jkl\n tyy \302\240" into "-34jkl\n tyy "
how can i do?

--
Posted via http://www.ruby-forum.com/.

From: Pen Ttt on
maybe match(/\S+/).to_s is not ok
would you mind to help me to find a way(one way not three way for the
following) to convert

"Dec 31, 2009/n \302\240" into "Dec 31, 2009"
"-34/n \302\240" into "-34"
"profit/n \302\240" into "profit"
--
Posted via http://www.ruby-forum.com/.

From: Robert Klemme on
On 24.07.2010 05:28, Pen Ttt wrote:
> maybe match(/\S+/).to_s is not ok
> would you mind to help me to find a way(one way not three way for the
> following) to convert
>
> "Dec 31, 2009/n \302\240" into "Dec 31, 2009"
> "-34/n \302\240" into "-34"
> "profit/n \302\240" into "profit"

What output do you expect for every input?

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
From: Pen Ttt on
i have solved it myself,thinks.
irb(main):026:0> "-34\n \302\240".gsub("\302\240","")
=> "-34\n "
irb(main):027:0>
irb(main):028:0* "-34jkl\n \302\240".gsub("\302\240","")
=> "-34jkl\n "
irb(main):029:0>
irb(main):030:0* "-34jkl\n tyy \302\240".gsub("\302\240","")
=> "-34jkl\n tyy "
irb(main):031:0>
irb(main):032:0* "Dec 31, 2009/n
\302\240".gsub("\302\240","").split("/n")[0]
=> "Dec 31, 2009"
irb(main):033:0>
irb(main):034:0* "-34/n \302\240".gsub("\302\240","").split("/n")[0]
=> "-34"
irb(main):035:0>
irb(main):036:0* "profit/n \302\240".gsub("\302\240","").split("/n")[0]
=> "profit"

--
Posted via http://www.ruby-forum.com/.

First  |  Prev  | 
Pages: 1 2
Prev: unsubscribe
Next: wxRuby listcontrol