[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Preg-match alternative in Lua
- From: Geoff Leyland <geoff_leyland@...>
- Date: Tue, 5 Jun 2012 18:02:31 +1200
On 5/06/2012, at 5:53 PM, Sandeep Ghai wrote:
>>> Hello Everyone,
>>> I just come across the 'preg-match'  function of PHP.
>>> Do we have similar function in Lua as well?
>> Is there a significant difference between preg-match and string:match? Because if not, then..
> Specifically Preg-match is for matching one value or one set of data
> with a given pattern..
> and what I tried with string.match, it matches the pattern and I am
> unable to extract a set of data in the matched pattern.
I'm afraid I'm not quite sure I understand, but does the following do what you mean by "extract a set of data"?
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> =("test a123a test"):match("a(%d+)a")