 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Mon Jun 26, 2006 9:58 am Post subject: string.find - strange result |
|
|
I am getting a 'strange' result using string.find to find a '.' (full stop) in a string. The function always returns 1 regardless of where the full stop is. The code below illustrates the issue. It prints two numbers the top one should be the position of the full stop within the string "abcdef.", but always returns 1.
The second line shows the correct behaviour for the letter e. Am I doing something silly here ?
| Code: | screen:print(10,10,string.find("abcdef.","."),Color.new(255,255,255))
screen:print(10,20,string.find("abcdef.","e"),Color.new(255,255,255))
screen:flip()
screen.waitVblankStart()
pad = Controls.read()
while not pad:start() do
pad = Controls.read()
end |
TIA,
JC |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Mon Jun 26, 2006 10:40 am Post subject: |
|
|
string.find doesn't just search for a string, it searches for a pattern. This page gives more info. If you do something such as string.find("abcdef.",".",1,true) it will disable pattern matching and just search for the string. _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Mon Jun 26, 2006 11:16 am Post subject: |
|
|
Thanks Drakonite,
| Code: | | string.find("abcdef.",".",1,true) |
Does the trick.
Regards,
JC |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|