I recommend you check out the API for the Pattern class.