Let says I have a string that says and the cow went @moo, and I want to only select moo… how would I go about that?
Let says I have a string that says and the cow went @moo ,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The regular expression
@([^ ]*)means: find the character@, then get all the characters afterward until a space is encountered (or implicitly the end of the string). Any part of the regex enclosed in parenthesis is stored and returned in an array. The first element is always the entire match, in this case@moo, afterwards the match inside each parenthesis in the regex from left to right.