I was looking at this about a week ago, and I decided that it might be worthy of a blog post. Part of the parsing of Stockholm files in Jalview utilizes the power of regular expressions, and Jalview uses the com.stevesoft.pat package. It simplifies some of the syntax; a tutorial is online here.
With this package you can create Regex objects and compile and match regular expressions. The Stockholm file parser detects the end of the file, annotation and sequence lines, and parses lines using regular expressions.