Raised This Month: $ Target: $400
 0% 

Matching strings with wildcard in middle


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-03-2009 , 12:42   Matching strings with wildcard in middle
Reply With Quote #1

So.... I have the strings
Code:
new string[] = "pp_area_ent";
new match[] = "pp_%s_ent";
I need a function to behave like equali and so I have:
Code:
SmartEquali( const string[], match[], strcomp_len )
{
	new wildcard = containi( match, "%s" );
	// if no wildcard or wildcard is at end of string
	if( wildcard == -1 || (wildcard >= strcomp_len && strcomp_len > 0) ){
		if( strcomp_len != -1 ){
			if( equali( string, match, strcomp_len ) )
				return true;
		}
		else{
			if( containi( string, match )!=-1 )
				return true;
		}
		return false;
	}
	else{
		new match_start[32], match_end[32];
		copy( match_start, 31, match );
		match_start[wildcard] = 0;
		copy( match_end, 31, match[wildcard+2] );
		return (SmartEquali( string, match_start, wildcard ) && SmartEquali( string, match_end, -1 ))
	}
	return false;
}
Anyone see problems with it? (Haven't been able to test it)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode