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 2 of 2

Thread: parsing string

  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    parsing string

    can someone help me .

    If I have a var x=abccddd!dkjfkdjfkldjf
    How can I parse all before teh ! in one variable and everything after the ! in another variable?

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You can use split(); It will split the string on the '!' and load them into an array.
    Code:
    <script type="text/javascript">
    var x = "abccddd!dkjfkdjfkldjf";
    var a = x.split("!");
    document.write("before '!' " + a[0] + " after '!' "  + a[1]);
    </script>


  •  

    Posting Permissions

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