In California, alimony is awarded only for lengthy marriage. Any marriage longer than 10 years is considered lengthy. The basic formula is alimony lasts half of the marriage. You are right that typically if you remarry within this payment period alimony will terminate.
That being said, the judge has sole discretion of awarding alimony. There are many factors to be considered other than the length of the marriage, such as age, health, earning capacity, etc.
Search CA family code 4320.