The task at hand is to find all the words greater than 1 letter in length that are capitalized AND the position of those words in a line. I am using the search pattern below for what it is worth and it does what I need
I put it all in a loop and find all the instances of capitalized words in the line and I store them in an array. Roughly the code is as below. This all works fine.
match = re.Search( myLine )
while match isa RegExMatch
result = match.SubExpressionString(0)
match = re.Search // Get the next match
Now I have this array of capitalized words but for my purposes, I also need their position in the line.
I could go through the array asCapital and with multiple uses of
InStr I could find the position in the line of all these words that I have found. But this seems a little “inefficient” in that I am effectively searching the line twice. Once with RegEx and then a second time using the found words themselves.
I just wonder if there is something using RegEx alone that provides the answer to both these items: the found words and the positions of those words. I am hoping that if I knew RegEx better, there would be a simpler answer. The Regex has to “know” where it is as if finds these capitalized words so it can progress to the next search in the loop.
Is there something more elegant?