[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Matching -- in a string
- From: Peter Odding <xolox@...>
- Date: Sat, 05 Jan 2008 13:40:59 +0100
'-' has a special meaning as a pattern item. You can either escape it
with %- or use the optional fourth parameter to string.find that turns
off pattern matching:
> = string.find(a, '%-%-')
17 18
> = string.find(b, '%-%-')
nil
> = string.find(a, "--", 1, true)
17 18
> = string.find(b, "--", 1, true)
nil
peterhickman schreef:
I am trying to do the following:
a = 'this line has a -- comment'
b = 'this line does not'
print(string.find(a,"--"))
print(string.find(b,"--"))
but in both cases the results are
1 0
1 0
how do I match "--" in a string?
--
Fear is Money