[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Help with my horrible function...
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 12 Jun 2001 15:58:28 -0300
> Is there a pattern that can be used to capture sequences of one or more
> different characters?
I am afraid not. You should use regular code. The following fragment extracts
all sequences of two or more equal characters of a string `s':
local i = 1
local len = strlen(s)
while i <= len do
local j
local pat = gsub(strsub(s, i, i), "(%W)", "%%%1")
pat = pat .. pat .. "+"
j, i = strfind(s, pat, i)
print(strsub(s, j, i))
i = i+1
end
-- Roberto