Re: idiom for iterating

Chris Babcock <[email protected]> Wed, 22 Apr 2009 10:53:57 -0700
Newsgroups gmane.mail.spam.crm114
Organization Kolonel Panic
Message-ID <[email protected]>
On Wed, 22 Apr 2009 16:25:43 +0200
Thomas Michael Hagen <[email protected]> wrote:

> 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?

Try "match [:file:] (::) /^/" before going into your loop. That will
position the string pointer to the begining of the variable... or you
can spend some hours combing through your code to see if your opening
marker ended up as part of another match prior to this section of code.

It's always so much easier to solve others problems than your own. I
have a similar parsing situation involving a flatfile user registration
database that contains user-formated data. Not even all the email
(Email:|E-mail:) fields have the same label! The only field that I can
parse on is the "User:" field at the begining of the record. My first
draft used an idiom like: 

	{
	match (:: :record:) /(User:.+?)User/
	# Do stuff
	alter (:record:) //
	liaf
	}

Chris

------------------------------------------------------------------------------
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

_______________________________________________
Crm114-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crm114-general
signature.asc (application/pgp-signature, 489 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQEcBAEBAgAGBQJJ71m2AAoJEASgqNsqZfCHfQIH/0r9r3jjwCcJL+Ro0QttHPYy
IVyLPTSGTnenFo/gUP9/HReg0dpdGZ3c5ebxzmoOoTKi40w6CXfup5cVsvvZZqYd
T+kz23C0bcQcfO1xl+X7OIEyRcY02ThD/+C5StKd7ytRsfnoZRuje7GiFwkaK825
JmaGZ4DkPrvwSupDunL6y5NetK9YCJKP88EcqBEWCIn+DqMMHXUmWG0v3106I9dP
GlonpQb6WDdzXhs78uSJr889PWOTcywAlHcfoD+DdbmuUXQi8AjScNvpITdlDgV+
WElhr1IXvNdMcxOPL6pnTmwvwfJgQolzELM/7TcZLsMxOCEUpeO14fUsA5VARPY=
=j7nf
-----END PGP SIGNATURE-----