lua-users home
lua-l archive

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

> 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

-- Roberto