I am a Chinese citizen holding a HK SAR passport. How long am I able to visit the UK within a 365-day period?
My stamp is for 6 months. Could I leave within 6 months but re-enter again a couple of weeks for another 6 months?
In principle you can show up at a port of entry the day after you left and apply for leave to enter, and in principle the border officer can grant you a new 6 months.
The odds of this happening in practice are not good.
The actual rules are not based on particular numbers, but on the fact that you're not supposed to (among other things) "live in the UK for extended periods through frequent or successive visits". If you try to enter again right at the tail of a multiple-months stay, the border officer is going to be rather suspicious that this is what you're doing, and getting in is going to depend on you ability to convince him, then and there, that you are in fact "genuinely seeking entry as a general visitor".
This can work, if you're lucky and have a really good and well-documented explanation ready. It can very easily not work too, in which case you'll have a black mark in your immigration record and only very limited opportunity to remedy that afterwards.
For a reasonable chance of not running into such problems, it is generally recommended to stay away from the UK for at least as long as your last visit, unless everything fits within a single 6-month period. But there's no hard and fast rule.
How long am I able to visit the UK within a 365 day period?
There is no specific day-count limit to the time a visitor can spend in the UK. This section of the guidance addresses the question directly...
There is no specified maximum period which an individual can spend in the UK in any period such as ‘6 months in 12 months’. However, if it is clear from an individual’s travel history that they are making the UK their home you should refuse their application.
Source: Visitor Guidance
Six months is a good benchmark because if you are in the UK for more than 6 months you are spending more time here than in your own country, and that's something they do not like.
could I leave within 6 months but re-entry again couple of weeks for another 6 months?
This is covered in Paragraph 20 of the rules...
A. Leave to enter or remain in the United Kingdom will usually lapse on the holder going to a country or territory outside the common travel area. However, under article 13 of the Immigration (Leave to Enter and Remain) Order 2000 such leave will not lapse where it was given for a period exceeding six months or where it was conferred by means of an entry clearance (other than a visit visa).
Rough translation: When you leave the UK your stamp becomes invalid (unless you have an entry clearance), so if you get in a few days later, you will get a new stamp with (all other things being equal) a new 6 months.
The next part of Paragraph 20 introduces the notion of 'unspent leave' and explains the conditions under which the 'stamp' will become invalid...
Those who seek leave to enter the United Kingdom within the period of their earlier leave and for the same purpose as that for which that leave was granted, unless it (i) was for a period of six months or less; or
Each visit will entail a landing interview and consecutive visits make the landing interview more probing.