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
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts

    How to find a string within a string?

    In a messaging application I am creating, I need to find any instances of '@'. This isn't where I am having trouble though. Once the '@' is found, I need to get the string that comes after it but before any spacing. Example: "@Elitis Hello World". In that example I'd need to find the entire string '@Elitis' and save it into a variable. The problem is that the '@' could be anything: '@Shrimp', '@Jouster', etc.

    I know about .search, and .test but would those be of any use in this situation?
    Last edited by elitis; 04-02-2013 at 03:45 PM.
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps

  • #2
    New Coder
    Join Date
    Mar 2011
    Location
    England
    Posts
    29
    Thanks
    0
    Thanked 5 Times in 5 Posts
    regular expressions, once you understand them there just SO bloody useful..

    http://jsfiddle.net/2DR7f/

    i think this is what your after?

  • #3
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts
    Wow, honestly didn't think it would be that simple... thanks.
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps

  • #4
    New Coder
    Join Date
    Mar 2011
    Location
    England
    Posts
    29
    Thanks
    0
    Thanked 5 Times in 5 Posts
    your welcome


  •  

    Posting Permissions

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