sub-Extractor Pattern

I need to extract the info from the following HMTL

~@imageTitle@~

The problem is some of the images don't have id. So the HTML will be like this:

~@imageTitle@~

How do I use sub_extractor pattern to extract the id (be null if it doesn't exit) and title?

Thanks a lot!