The problem of inferring XML schemas reduces to inferring deterministic regular expressions from a set of sentences. A subclass of restricted regular expressions which commonly occur in practical XML schemas was proposed. An algorithm for inferring this kind of regular expressions was described. The algorithm first constructs the corresponding automata according to the sentence set, then infers the regular expression from the automata and the sentence set. The complexity of the algorithm is max(O(|V|+|E|), O(L))where V and Eare the set of states and the set of edges of the constructed automata respectively, and Lis the total length of sentences. The termination and correctness of the algorithm were proved.