This simple tutorial should get you started with grabbing text from a Google Doc for other uses. You could certainly make a lot of changes to the code to introduce more search rules. Likewise, you could use regular expressions to search for some really cool stuff, but for a simple overview this should get you started.
This post provides a detailed how-to of getting a list of information from the document that you have noticed are between two sets of characters.
Source: Google Apps Script: Get Google Doc Text Based on Reference Characters – Yagisanatode