[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Cropping text strings

Cryptographic_ICE

9/17/2007 7:13:00 PM

Hello,

This statement here can return a very long paragraph
<%=h openjob.ProblemDesc %>

Is there a way to trim it to say the first 50 characters? In VBScript
I would use Left(). (I am working in ruby on rails if that matters)

7 Answers

Rob Biedenharn

9/17/2007 7:31:00 PM

0



Morton Goldberg

9/17/2007 7:41:00 PM

0

On Sep 17, 2007, at 3:20 PM, Glen Holcomb wrote:

> openjob.ProblemDesc[0..49] should do the trick.
>
> On 9/17/07, Cryptographic_ICE@yahoo.com
> <Cryptographic_ICE@yahoo.com> wrote:
>>
>> Hello,
>>
>> This statement here can return a very long paragraph
>> <%=h openjob.ProblemDesc %>
>>
>> Is there a way to trim it to say the first 50 characters? In VBScript
>> I would use Left(). (I am working in ruby on rails if that matters)

As will the following:

openjob.ProblemDesc.first(50)

Regards, Morton

Cryptographic_ICE

9/17/2007 8:44:00 PM

0

On Sep 17, 3:41 pm, Morton Goldberg <m_goldb...@ameritech.net> wrote:
> On Sep 17, 2007, at 3:20 PM, Glen Holcomb wrote:
>
> > openjob.ProblemDesc[0..49] should do the trick.
>
> > On 9/17/07, Cryptographic_...@yahoo.com
> > <Cryptographic_...@yahoo.com> wrote:
>
> >> Hello,
>
> >> This statement here can return a very long paragraph
> >> <%=h openjob.ProblemDesc %>
>
> >> Is there a way to trim it to say the first 50 characters? In VBScript
> >> I would use Left(). (I am working in ruby on rails if that matters)
>
> As will the following:
>
> openjob.ProblemDesc.first(50)
>
> Regards, Morton

Thank you it worked great!

Daniel DeLorme

9/17/2007 11:33:00 PM

0

Glen Holcomb wrote:
> openjob.ProblemDesc[0..49] should do the trick.

Hate to be anal, but that would return the first 50 *bytes*, not characters.

Daniel

Rob Biedenharn

9/18/2007 4:55:00 AM

0



Peña, Botp

9/19/2007 1:44:00 AM

0

From: Glen Holcomb [mailto:damnbigman@gmail.com]
# On 9/17/07, Daniel DeLorme <dan-ml@dan42.com> wrote:
# > Hate to be anal, but that would return the first 50 *bytes*, not
# > characters.
# Good point, I wasn't thinking in Unicode.

ruby1.9 http://eigenclass.org/hiki.rb?Changes+in+Rub...

Bertram Scharpf

9/19/2007 2:30:00 PM

0

Hi,

Am Dienstag, 18. Sep 2007, 04:41:14 +0900 schrieb Morton Goldberg:
> On Sep 17, 2007, at 3:20 PM, Glen Holcomb wrote:
>>> Is there a way to trim it to say the first 50 characters?
>
> As will the following:
>
> openjob.ProblemDesc.first(50)

Cool. Here are two other ones:

openjob.ProblemDesc[ 0, 50]
openjob.ProblemDesc[ /.{50}/u]

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...