A framework for extracting data from documents of various kinds such as text files and Web pages using examples. Once the user highlights one or two examples of each field in the text file in (a), FlashExtract extracts more such instances and arranges them in a structured format in the table in (b). This is enabled by synthesis of a program in the domain-specific language (DSL) in (c) that is consistent with the examples in (a) followed by execution of that program on the text file in (a).