Thanks for responding Mash (Mike?). I meant that i wanted the parsing and matching logic to stay in regex so that i could use any programming language (VB, SQL, C#, etc.) that supports regexs. I am trying this in VBA but would eventually like to run this regex in Oracle PL/SQL. Any additional parsing would be a bit of a pain in PL/SQL.
The source is a text string about 100 characters long. An ID could be anywhere in there. An ID could be preceeded by any character and followed by any character. If the preceeding or following characters are a dash or a digit, then the string could have different meaning (it could then be a date, for ex.).
While I can understand why you would want to do that, it not necessarily a practical approach to using regexes. In truth it is a bad idea. The reason we ask in the posting guidelines which programming language you are using is because regular expression implementation across languages is not universal and some patterns created for one implementation will not be portable. You have no guarantee a regex written for one language will work for another. Implementations differ in features supported and syntax, and the differences are not minor.
Buckley's suggestion is still very sound as it uses widely supported features, and it used a very powerful basic feature, grouping. http://regexadvice.com/blogs/mash/archive/2007/06/01/You_2700_ve-got-your-sub_2D00_matches-in-my-matches.aspx
Logically , implementation supporting, your pattern and your coding logic doesn't change but your implementation will, since it has to anyway. You won't be using the same code for VBScript that you'd use for C#. You could use the same pattern and logic for C# or using a different pattern since C#'s regex engine is much more powerful.
"In theory, theory and practice are the same. In practice, they are not."