1. A data compression method that generates compressed data from a data string to be compressed, comprising: an input step of inputting and retaining, by an input unit, the data string to be compressed in the input buffer; a list generating step of generating and retaining, by a recent-match-position-list generating unit, a recent match position list having stored therein a relative position where each character string having a predetermined length starting at each address in the input buffer has most recently appeared; a candidate acquiring step of acquiring, by a repetition candidate acquiring unit, with the use of the recent match position list, a repetition candidate at a position where a character string at a coding position has previously appeared; a match detecting step of comparing, by a match detecting unit, a character string starting at the position of the acquired repetition candidate and the character string at the coding position, and detecting a matching character string from the position of the repetition candidate; and a code generating step of coding, by a code generating unit, the detected matching character string.