simple jsp string comparison

Discussion in 'Java' started by Jason, Sep 18, 2003.

  1. Jason

    Jason Guest

    Hi,

    In JSP do we have a built in function like left() if we want to evalue a
    string's left some characters?
    Thanks.

    Jason
     
    Jason, Sep 18, 2003
    #1
    1. Advertising

  2. Jason

    KC Wong Guest

    > In JSP do we have a built in function like left() if we want to evalue a
    > string's left some characters?
    > Thanks.


    http://java.sun.com/j2se/1.4.2/docs/api/

    Look at class java.lang.String, method startsWith(String prefix) and
    startsWith(String prefix, int toffset).

    Always refer to the API docs first.
     
    KC Wong, Sep 18, 2003
    #2
    1. Advertising

  3. Jason

    Phil Hanna Guest

    On Thu, 18 Sep 2003 14:58:18 +0800, "Jason" <>
    wrote:

    >Hi,
    >
    >In JSP do we have a built in function like left() if we want to evalue a
    >string's left some characters?
    >Thanks.


    String a = "ABCDEFG";
    String firstFour = a.substring(0, 4);

    firstFour will contain "ABCD"

    --
    Phil Hanna
    Author of JSP 2.0: The Complete Reference
    http://www.philhanna.com
     
    Phil Hanna, Sep 20, 2003
    #3
    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. Replies:
    0
    Views:
    4,403
  2. Replies:
    21
    Views:
    1,414
    Alex Vinokur
    Aug 18, 2007
  3. Smithers
    Replies:
    12
    Views:
    1,183
    Ben Voigt [C++ MVP]
    Jul 7, 2009
  4. Deepu
    Replies:
    1
    Views:
    244
    ccc31807
    Feb 7, 2011
  5. db
    Replies:
    7
    Views:
    264
Loading...

Share This Page