Upright judge replaced by king in purge (5)
I believe the answer is:
erect
'upright' is the definition.
(I know that upright can be written as erect)
'judge replaced by king in purge' is the wordplay.
I cannot really understand how this works, but
'king' could be 'er' (abbreviation for Edward Rex, various English kings) and 'er' is found within the answer.
The remaining letters 'ect' is a valid word which might be clued in a way I don't understand.
This explanation may well be incorrect...
Can you help me to learn more?
(Other definitions for erect that I've seen before include "Found" , "Upright; put up" , "Assemble" , "Upright or vertical" , "Unbowed" .)