Of course it's possible; how do you think the Mystery Gift function in Raptor works? :P
You should use a regular expression to find the text you need. For example, if your text doesn't contain the symbol '#', you could enclose the code in '#'s, like so: #XdQ8sK9X#
Then, use a regular expression to search for a string in between two '#'s:
Code:
string[/#(.*?)#/]
code=$1
The '/'s around a string mean the string is treated as a regular expression. In a regular expression, '.' stands for any character, '*' means repeat the previous character an arbitrary number of times, and '?' after the '*' means it stops as soon as it gets to the second '#' (without the '?', it would continue as '#' falls under 'any character'). The brackets around part of the regular expression in this case are used to save the contents of the brackets (the code) into a global variable ($1, as it's the first pair of brackets. If you had another pair, their contents would be in $2 and so on). After using the regular expression, it's a good idea to copy the contents of the $1 variable to your own variable, as next time you use a regular expression, the $1 variable is overwritten.