-2

I am trying to put together a regexp in VBA, but even in ruby I can't get it right.

the string:

<thead class="thead"><tr><th>FECHA</th><th>ITLUPVALOR</th><th>ITLUPPLAZO</th><th>ITLUP30DIAS</th><th>ITLUP60DIAS</th><th>ITLUP90DIAS</th><th>ITLUP180DIAS</th><th>ITLUP270DIAS</th><th>ITLUP360DIAS</th><th>ITLUP720DIAS</th><th>ITLUP1080DIAS</th><th>ITLUP1440DIAS</th><th>ITLUP1800DIAS</th></tr></thead>

what i have tried:

/(?:<thead class=\"thead\"><tr>)(<th>[^<]+?<\/th>)+(?:<\/tr><\/thead>)/m

The idea here (http://rubular.com/r/BpbPszctTw) was to have 9 submatches instead of one.

What am I missing?

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125
  • Please [do not "parse" HTML with regexes](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags), better use a parser. – tessi Jul 09 '13 at 23:03
  • Please do define acronyms upon first use. Is that Visual Basic for Applications or Virtual Backup Appliance? Also, Ruby's regexp may not be the same as either of those. – vgoff Jul 09 '13 at 23:43
  • Please copy the pattern and target strings into your question. While Rubular.com seems stable, link rot always occurs, and when it does your question will be worthless without that information. As is, you're asking us to chase your code across the internet just to help you. – the Tin Man Jul 09 '13 at 23:46

2 Answers2

1

Sorry, but a regex repeating group will only capture the last match in a group. See http://www.regular-expressions.info/captureall.html for more info.

Update: True, but if you let the regex match do the repeating for you, as in the other answer, you can get multiple matches, per http://rubular.com/r/BclU13qWYm ! In other words, accept the other answer, not this one. :-)

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
0

With this pattern you can obtain what you want:

/<thead class="thead"><tr>|\G<th>([^<]+)<\/th>/

Just remove the first result.

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125