Regular Expressions: Named groups in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Medwar19
    New Member
    • Aug 2010
    • 17

    #1

    Regular Expressions: Named groups in VBA

    Hi,

    Is it possible to used named groups in VBAs version of Regular Expressions (Regexp)

    Example match groups for extracting dates from strings:

    (?:(\d{2})\.(\d {2})\.(\d{4})\s (\d{2}):(\d{2}) :(\d{2}))|(?:(\ d{4})-(\d{2})-(\d{2})\s(\d{2} ):(\d{2})

    will returns DD.MM.YYYY or YYYY-MM-DD in submatch groups but the ordering is mixed up depending on the formatting.

    A better solution would be:

    (?:(?<Day>\d{2} )\.(?<Mon>\d{2} )\.(?<Yr>\d{4}) \s(?<hh>\d{2}): (?<mm>\d{2}):(? <ss>\d{2}))|(?: (?<Yr>\d{4})-(?<Mon>\d{2})-(?<Day>\d{2})\s (?<hh>\d{2}):(? <mm>\d{2}):(?<s s>\d{2}))

    Which names the groups using the <name> method.

    These strings work fine in VB.net but not in VBA???

    Thanks,

    Mark
Working...