Yes, you can go in and out as many times as you like, but the periods spent out of the country are added on to your qualifying period, and I don't think it would be wise to stay away for more than a few weeks.
That's what happened with my ex anyway.
I would advise you to check the latest rules with UKBA though.