Sorted out first part of regexp matching