Results 1 to 4 of 4

Thread: Left in Javascript ?

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Left in Javascript ?

    Hi all, can anyone please give me a regular expression or similar to grab the first character of a string please?
    I.e. (Like VB's Left function) returning "A" from the string "Alex" ?

    Thanks All !

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    the substr function

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Try this.

    Code:
    myFirstChar = myString.match(/^./);
    If that doesn't work, then find a book.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  4. #4

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Thanks - big shout out to both of yous guys !

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width