Skip to main content
October 13, 2008
Question

REMatch Assistance?

  • October 13, 2008
  • 1 reply
  • 250 views
I am trying to write a regex that will return all of the rows of a table that contain the word 'Online' within the row.

This is what I have so far:

REMatch('(?i)<tr class="(dark|light)[^>].+?Online{1}.+?[^<]+</tr>',objGet.FileContent)

This gives me the correct number of rows, but it is not stopping at the first </tr> that it comes across.

E.g. If my table is as follows
<tr>...Row 1 - blah - Online...</tr>
<tr>...Row 2 - blah - Offline...</tr>
<tr>...Row 3 - blah - Online...</tr>

The regex is returning the following
Result 1 = '<tr>...Row 1 - blah - Online...</tr>'
Resutl 2 = '<tr>...Row 2 - blah - Offline...</tr><tr>...Row 3 - Blah - Online...</tr>

Any clues (or another web resource) on how to get the Regex to only return the <tr>...</tr>'s that contain the word Online and ignore the rest?
This topic has been closed for replies.

1 reply

Inspiring
October 13, 2008
> REMatch('(?i)<tr
> class="(dark|light)[^>].+?Online{1}.+?[^<]+</tr>',objGet.FileContent)

CF regexes are greedy unless you tell them not to be, so they will match as
much as they can.

http://livedocs.adobe.com/coldfusion/8/regexp_11.html

--
Adam