matching strings problem
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

matching strings problem

Started by blackwings, 13 March, 2005, 07:49:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

I have a problem to make a match between a string found through search with another string in a table. Here is what I'm trying to do =
function DataArrival(user,data)
	local inMsg = "(%p[^%.]+%p%S+)"
	if inMsg then
		user:SendData(Bot,"STRING FOUND")
		if inMsg == (tLines[inMsg]==1) then -- the script works until I try to match here
			user:SendData(Bot,"THE STRINGS MATCH")
		end
	end
end


Optimus

Quoteif inMsg == (tLines[inMsg]==1) then -- the script works until I try to match here
^^ This looks abit wierd, you need todo it in a way like this.

if tLines[inMsg] == 1 then

^^ that is how a match should work

- Optimus

blackwings

#2
QuoteOriginally posted by Optimus
Quoteif inMsg == (tLines[inMsg]==1) then -- the script works until I try to match here
^^ This looks abit wierd, you need todo it in a way like this.

if tLines[inMsg] == 1 then

^^ that is how a match should work

- Optimus
Oh, sorry, seems like I missed that somone had answer the thread :P I tested your suggestion, but it still wont work when matching the string:( I have also tried to use senddata to see what the scripts finds, but the script shows the magic chars, not the string it found, so I can't really check whats wrong for myself :( Can anyone say whats wrong??? (my guess is that it doesn't remeber the string it founds, so how do I make so it remebers?) =
Bot = "test"

tLines = {
[".no-ip.com"]=1,
}

function DataArrival(user,data)
	local inMsg = "%p[^%.]+%p%S+"
	if inMsg then
		user:SendData(Bot,"STRING FOUND")
		if tLines[inMsg] == 1 then -- stops working here
			user:SendData(Bot,"THE STRINGS MATCH")
		end
	end
end


bastya_elvtars

Where is string.find?  8o
Everything could have been anything else and it would have just as much meaning.

blackwings

#4
QuoteOriginally posted by bastya_elvtars
Where is string.find?  8o
you mean =
if string.find(data, inMsg,1,1) then
it doesn't work  :(


bastya_elvtars

if string.find(data, inMsg)
you mean?
Everything could have been anything else and it would have just as much meaning.

blackwings

QuoteOriginally posted by bastya_elvtars
if string.find(data, inMsg)
you mean?
does the same thing as this =
if inMsg then
something is missing I guess :(  ?(


Jaras

#7
it looks so simple, that probably i've missed something very, very important:

QuoteNot quite originally posted by blackwings
Bot = "test"

tLines = {
[".no-ip.com"]=1,
}

function DataArrival(user,data)
	local inMsg = "%p[^%.]+%p%S+"
	if inMsg then -- this is always a good condition, coz u're making this string not nil one line above...
		user:SendData(Bot,"STRING FOUND")
		if tLines[inMsg] == 1 then -- u mean if tLines["%p[^%.]+%p%S+"] == 1?
			user:SendData(Bot,"THE STRINGS MATCH")
		end
	end
end

try this, but i'm not sure if it works:
sBot = "test"

tLines = {
	[ ".no-ip.com" ] = 1,
}

function DataArrival( curUser, data )
	local sData = string.lower( string.sub( data, 1, -2 ) )
	local sPattern = "(%p[^%.]+%p%S+)"
	local _,_,sBadString = string.find( sData, sPattern )
	if sBadString then
		curUser:SendData( sBot, "STRING FOUND" )
		if tLines[ sBadString ] == 1 then
			curUser:SendData( sBot, "THE STRING MATCH" )
		end
	end
end

p.s. but seriously - this isn't some kind of joke? if it's not hit me hard with mistakes i've made - whole code looks so innocent =]

blackwings

QuoteOriginally posted by Jaras
p.s. but seriously - this isn't some kind of joke? if it's not hit me hard with mistakes i've made - whole code looks so innocent =]
well, this code is for testing for a thing I can't seem to get to work. I have tried various ways, including what you did(but I tried your code, in case if I made a mistake before), but none of my tries have worked :(

I have read about similar things in the lua 5 mannual, but still no succes :(


SMF spam blocked by CleanTalk