A partial-character-string position detecting device for detecting partial character positions by secure multiparty computation taking inputs of a secret text <t> of a text t having a length of n, a secret text <p> of a pattern p having a length of m, a secret text <c> of a vector c having a length of m, and a secret text <E> of a matrix E of m rows and n columns and outputting a secret text <H> of a matrix H of m rows and n columns, the partial-character-string position detecting device comprising: a first matrix generating part generating a secret text <F> of a matrix F of m rows and (n + 1) columns in which F[i][j] = E[i][j + i mod n + 1], where it is assumed that E[i][n] = ¬ c[i]; a second matrix generating part generating a secret text <F'> of a matrix F' of m rows and (n + 1) columns, wherein, in the secret text <F'>, F'[i][j] = 1 is set if c[i] = 0 or if c[i] = 1 and F[k][j] = 1 for every k that is successively c[k] = 1 when k is incremented by 1 from i, otherwise, F'[i][j] = 0 is set; and a third matrix generating part computing <H[i][j]> = <F'[i][j - i mod n + 1]> ∧ <c[i]> ∧ ¬<c[i -1]> to generate the secret text <H>; wherein < • > denotes a secret text of • concealed by secret sharing; p[i] is an i-th element of the pattern p, t[i] is an i-th element of the text t, c[i] is an i-th element of the vector c, E[i][j] is an element in an i-th row of a j-th column of the matrix E, H[i][j] is an element in an i-th row of a j-th column of the matrix H; in the vector c, c[i] = 1 is set if p[i] is not a limitless gap representing a character string having an arbitrary length, otherwise, c[i] = 0 is set; in the matrix E, E[i][j] = 1 is set if c[i] = 0 or p[i] = t[j], otherwise, E[i][j] = 0 is set; and in the matrix H, H[i][j] = 1 is set if p[i] is the leading element of a partial character string resulting from separating the pattern p by the limitless gap and the partial character string appears in the j-th position in the text t, otherwise, H[i][j] = 0 is set. a first matrix generating part generating a secret text <F> of a matrix F of m rows and (n + 1) columns in which F[i][j] = E[i][j + i mod n + 1], where it is assumed that E[i][n] = ¬ c[i]; a second matrix generating part generating a secret text <F'> of a matrix F' of m rows and (n + 1) columns, wherein, in the secret text <F'>, F'[i][j] = 1 is set if c[i] = 0 or if c[i] = 1 and F[k][j] = 1 for every k that is successively c[k] = 1 when k is incremented by 1 from i, otherwise, F'[i][j] = 0 is set; and a third matrix generating part computing <H[i][j]> = <F'[i][j - i mod n + 1]> ∧ <c[i]> ∧ ¬<c[i -1]> to generate the secret text <H>; wherein < • > denotes a secret text of • concealed by secret sharing; p[i] is an i-th element of the pattern p, t[i] is an i-th element of the text t, c[i] is an i-th element of the vector c, E[i][j] is an element in an i-th row of a j-th column of the matrix E, H[i][j] is an element in an i-th row of a j-th column of the matrix H; in the vector c, c[i] = 1 is set if p[i] is not a limitless gap representing a character string having an arbitrary length, otherwise, c[i] = 0 is set; in the matrix E, E[i][j] = 1 is set if c[i] = 0 or p[i] = t[j], otherwise, E[i][j] = 0 is set; and in the matrix H, H[i][j] = 1 is set if p[i] is the leading element of a partial character string resulting from separating the pattern p by the limitless gap and the partial character string appears in the j-th position in the text t, otherwise, H[i][j] = 0 is set. p[i] is an i-th element of the pattern p, t[i] is an i-th element of the text t, c[i] is an i-th element of the vector c, E[i][j] is an element in an i-th row of a j-th column of the matrix E, H[i][j] is an element in an i-th row of a j-th column of the matrix H; in the vector c, c[i] = 1 is set if p[i] is not a limitless gap representing a character string having an arbitrary length, otherwise, c[i] = 0 is set; in the matrix E, E[i][j] = 1 is set if c[i] = 0 or p[i] = t[j], otherwise, E[i][j] = 0 is set; and in the matrix H, H[i][j] = 1 is set if p[i] is the leading element of a partial character string resulting from separating the pattern p by the limitless gap and the partial character string appears in the j-th position in the text t, otherwise, H[i][j] = 0 is set.