Murga-Projects Forums

Full Version: string.find bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have something like this in a loop

i=string.find(string,lookfor,icur,true)

In some cases, it seems that i is being set to 1 when a match is found at the end of the string, which caused my program to go into a loop. I fixed it by testing for i==nil or i<icur so that the test for not found would include i being set to 1 in addition to nil.

It's a complex program and I haven't been able to create a simple program that reproduces the situation.

Has anyone else ever encountered anything like this? Am I crazy? i should never get set to anything less than the starting position which is icur, right?

Quote:
i should never get set to anything less than the starting position which is icur, right?

That's true, as far as I can tell. I suppose it would depend on what the actual string and variable values are, though. We can speculate all we want, but unless you provide more specific info than i=string.find(string,lookfor,icur,true) all it's going to be is speculation.

Yep, need to see the string its failing on.
I'm not getting any bug type result here.

A return of nil seems to occur where appropriate.

Whats your hardware and os?
Reference URL's