The following regex will match words separated by spaces before a word starting with a @
character;
([^@\s]+ )+@[\w]{1,15}
For example, this will return two matches for the String:
User Name @username Text Text Text Text random @thing
User Name @username
Text Text Text Text random @thing
You can then select the second match to get the text you need. Alternatively, if you know what @thing
will be before compiling the regex (e.g. @response, @config, etc.) you can replace the @[\w]{1,15}
section of the regex with the specific @thing
to only retrieve the text you want.