A method for processing an electronic document (ED) to infer a sequence of section headings in the ED. The method includes generating, by a computer processor, based on regular expression matching of a predetermined section heading pattern and a plurality of characters in the ED, a list of candidate headings in the ED; generating, by the computer processor and based on the list of candidate headings, a list of chain fragments for inferring a portion of the sequence of section headings; and generating, by the computer processor and based on predetermined criteria, the sequence of section headings by merging at least two chain fragments in the list of chain fragments.