Irregular periods

Can you get pregnant if you have irregular periods? When to test?