Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts

    elementAt(str, idx, delim)

    Sometimes the simplest things stop me dead in my tracks...

    Could someone please explain why I can't use the string function, "elementAt"? I'm simply trying to parse a long comma delimited string. Writing it with substring and indexOf is fine, but I'd like to fully understand what's going on. Do I need the WMLScript String Library to use elementAt? Do I need to pay for that library? Where do I even download it?Some of these sites are so confusing. Also, since my string can get kind of lengthy, what is the function that will do this the quickest? I don't know, maybe I'm just tired, but it would sure be nice to have this all explained when I wake up in the morn.

    Thanks to all my helpers out there.

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by snoodle View Post
    Sometimes the simplest things stop me dead in my tracks...

    Could someone please explain why I can't use the string function, "elementAt"? I'm simply trying to parse a long comma delimited string. Writing it with substring and indexOf is fine, but I'd like to fully understand what's going on. Do I need the WMLScript String Library to use elementAt? Do I need to pay for that library? Where do I even download it?Some of these sites are so confusing. Also, since my string can get kind of lengthy, what is the function that will do this the quickest? I don't know, maybe I'm just tired, but it would sure be nice to have this all explained when I wake up in the morn.

    Thanks to all my helpers out there.
    I don't think elementAt() is a native javascript string method. A native method would look like:

    Code:
    str.elementAt(idx, delim)
    instead of:

    Code:
    elementAt(str, idx, delim)
    Here's a good number of examples on how to test a string in an Array:
    http://www.snook.ca/archives/javascr...sting_for_a_v/

    It might give you some Ideas.
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Why not just say str.split(delim)[idx] ?

  • #4
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thank you! split does the trick just fine.


  •  

    Posting Permissions

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