Hi Paul,
you can find some general information about Regular Expressions in IOS HERE.
Another useful link is the AS Regular Expressions section of the BGP Case Studies.
_64512 means one delimiter (Space/Blank, Tab, etc.) followed by 64512, e.g. " 64512".
(_64512) is the same thing, the parentheses group the expression _64512 so you can combine it with a quantifier.
* is a quantifier. It means 0 or more occurrences of the group. So (_64512)* matches an empty string (0), " 64512" (1), " 64512 64512" (2), " 64512 64512 64512" (3) and so on.
^ and $ match the beginning and the end of a string.
So the first line says the as-path has to begin with 64512, optionally followed by any number of repetitions of that AS, e.g. "64512 64512 64512" (Origin: 64512). The second line additionally allows optionally any number of occurrences of AS 64513 at the end of as-path, e.g. "64512 64512 64513 64513" (Origin: 64512 OR 64513). The first line seems to be somewhat redundant.
In a nutshell:
• minimum accepted AS_PATH: "65512"
• accepted AS_PATH expressions 1 and 2: "65512 65512 65512 (...) 65512"
• accepted AS_PATH expression 2: "65512 65513"
• accepted AS_PATH expression 2: "65512 65513 65513 (...) 65513"
• accepted AS_PATH expression 2: "65512 65512 65512 (...) 65512 65513 65513 (...) 65513"
It's not easy to explain ...
HTH
Rolf