idiom for iterating
Thomas Michael Hagen <[email protected]> Wed, 22 Apr 2009 16:25:43 +0200
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <[email protected]> |
normally, you would use the keyword <fromend> to iterate over matches
in a file. this works when the pattern is simple, like
/(what-you-want)(something-else)/.
however, when you are looking for something that looks like this:
/(start-tag)(you-want-this)(next-start-tag)/, the <fromend> keyword
will cause you to only match every second instance. the <fromnext>
keyword will cause you to match every instance but the first.
therefore, i have resorted to this clumsy hack:
match (:: :url: :text: :next-url:) [:file:] /(#http:.*?CET
....)(.*?)(#http:|$)/
isolate (:article:) /:*:url::*:text:/
call /:main:/ [:*:article:]
{
match <fromnext> (:: :url: :text: :next-url:) [:file:]
/(#http:.*?CET ....)(.*?)(#http:|$)/
isolate (:article:) /:*:url::*:text:/
call /:main:/ [:*:article:]
liaf
}
there must be a better way than duplicating all that code, right?
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p