regex - VBA multiple matches within one string using regular expressions execute method -


i'm trying match experience levels various positions based on 1. degree 2. years of experience. pattern simple (example: "bs/5" bachelors of science 5 years of experience. have entries follow scheme have multiple degrees , experience levels in same string (example: "bs/5-ms/2") considered equivalent. i've got basic function match , find substring pattern never returns more 1 match though i've set .global property true regexp object. ideas? code below:

on error resume next activeworkbook.vbproject.references.addfromguid "{3f4daca7-160d-11d2-a8e9-00104b365c9f}", 5, 5  dim theregex object dim thestring string   set theregex = createobject("vbscript.regexp")  regex     .multiline = false     .global = true     .ignorecase = false end  theregex.pattern = "([a-z][a-z][a-z]?/[0-9][0-9]?)"  thestring = "ms/9-phd/4"  set mymatches = theregex.execute(thestring)  debug.print "submatches.count: " & mymatches.item(0).submatches.count  if mymatches.count <> 0         mymatches             mymatchct = 0 .count - 1                     debug.print "mymatchct: " & mymatchct                     submtct = 0 .item(submtct).submatches.count - 1                         debug.print "submtct: " & submtct                         debug.print ("," & .item(mymatchct).submatches.item(submtct))                     next             next         end     else     debug.print "no matches" end if 

try changing line with regex

to

with theregex     .multiline = false     .global = true     .ignorecase = false end 

your on error resume next statement disguising error.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -