You have to use switch case statement and accordingly proceed with the process
For getting numbers you can use split activity
Arr = Str.split({"?",","},StringSplitOptions.None)
In this array are(1),arr(2),arr(3) are the numbers
And use str.Contains to check if it says middle,end ,largest for each string that you might find and give th logic in the switch case accordingly
Cheers