Cropping text strings

Discussion in 'Ruby' started by Cryptographic_ICE@yahoo.com, Sep 17, 2007.

  1. Guest

    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)
    , Sep 17, 2007
    #1
    1. Advertising

  2. Rob Biedenharn, Sep 17, 2007
    #2
    1. Advertising

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

    > openjob.ProblemDesc[0..49] should do the trick.
    >
    > On 9/17/07,
    > <> 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
    Morton Goldberg, Sep 17, 2007
    #3
  4. Guest

    On Sep 17, 3:41 pm, Morton Goldberg <> wrote:
    > On Sep 17, 2007, at 3:20 PM, Glen Holcomb wrote:
    >
    > > openjob.ProblemDesc[0..49] should do the trick.

    >
    > > On 9/17/07,
    > > <> 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!
    , Sep 17, 2007
    #4
  5. 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
    Daniel DeLorme, Sep 18, 2007
    #5
  6. Rob Biedenharn, Sep 18, 2007
    #6
  7. Peña, Botp Guest

    Peña, Botp, Sep 19, 2007
    #7
  8. 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-scharpf.de
    Bertram Scharpf, Sep 19, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FrankV
    Replies:
    0
    Views:
    376
    FrankV
    Nov 8, 2005
  2. Andrew Neiderer

    JAI example of cropping

    Andrew Neiderer, Sep 14, 2005, in forum: Java
    Replies:
    2
    Views:
    9,988
    Martin Trobec
    Sep 17, 2005
  3. Darrel

    Cropping an image

    Darrel, Apr 23, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    477
    Kevin Spencer
    Apr 23, 2006
  4. Kamus of Kadizhar

    Cropping log files

    Kamus of Kadizhar, Dec 16, 2003, in forum: Python
    Replies:
    6
    Views:
    313
    Gerrit Holl
    Dec 17, 2003
  5. JJ
    Replies:
    3
    Views:
    704
    PJ on Development
    Nov 19, 2007
Loading...

Share This Page