Is “ex” the abbreviation for “for example”?

The correct abbreviation for “for example” is e.g., not “ex.” “Ex” is sometimes used in informal language, but it’s best to avoid it, since this abbreviation can be confused with other uses of “ex,” such as its use to mean “former” in a term like “ex-boyfriend.”