lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Jose!

It's Just a suggestion.

I think in your particular case it is important to use something as

	a, b = string.find (string.lower(s), string.lower(pattern1) )
	c, d = string.find (string.lower(s), string.lower(pattern2) )

to be able to parse <> tags written in any case. Of course, if you do
not generate these html by yourself :)

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Jose Marin
Sent: Wednesday, May 31, 2006 8:40 PM
To: Lua list
Subject: Re: Reading substrings



Warning: need error checking, and change the BASIC
style variables!


function extractContents(s, pattern1, pattern2)
local a, b, d, c

	a, b = string.find (s, pattern1 )
	c, d = string.find (s, pattern2 )

	return string.sub(s, b+1, c-1)
end


To print the title of a html page (loaded on the
'page' variable):

print( extractContents(page, "<TITLE>", "</TITLE>"))

Hope this could be useful to someone...


--- Andrew Wilson <agrwagrw@gmail.com> escreveu:

> Sure, it would be useful, send the code snippet.
> AGRW
> 
> On 5/31/06, Jose Marin <jose_marin2@yahoo.com.br>
> wrote:
> >
> > If it's useful to someon, I've solved today, using string.find!
> >
> > Thanks for your tips, guys!
> >
> >
> >
> >
> >
> >
> 

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger 
http://br.beta.messenger.yahoo.com/