I would also use the ant-contrib PropertyRegex task.
The following snippet only works if the input string follows the convention you used in your description and you can also use it to extract the other numbers by changing the value entered in the select tag.