[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Implementing 'or' in gsub() pattern
- From: "Peter Shook" <pshook@...>
- Date: Mon, 31 Mar 2003 15:27:59 -0500
Try pattern = "(%S+)". This will match groups of non-spaces. Note that the
parens are to capture the match.
- Peter Shook
> local word_table = { n = 0 }
> gsub(text, pattern, function (word)
> tinsert(%word_table, word)
> end)
>
> for separating tokens, but I couldn't find out a way to split strings like
> "Hello, world!" into ["Hello", ",", "world", "!"] -- for what I'd use a
> pattern like "\w+|[^\w\s]+".
> Any suggestions about how to implement it?