I am trying to break down the following string:
"@command Text1 @command2 Text2"
in Ruby. I want to take out "Text1" and "Text2" in an array. To do this I am using the scan method and using this:
text.scan(/@* (.*?)(@|$)/)
However, when run, the script is pulling the @ symbol in the middle as a separate match (presumably because the parenthesis are used in Ruby to indicate what string you want to pull out of the input):
Text1
@
Text2
My question is, how can I pull out Text1 and Text2 bearing in mind the expression needs to stop matching at both "@" and the end of a string?