Raised This Month: $ Target: $400
 0% 

Help with RegExp (?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 11-23-2011 , 16:40   Help with RegExp (?)
Reply With Quote #1

How to remove from string all ^x, where x is digit from 0 to 8 ?

Example:

^1P^8layer^0 -> Player
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-24-2011 , 03:15   Re: Help with RegExp (?)
Reply With Quote #2

\^[0-8] is the pattern
but amxx doesn't have regex_replace_all, and such simple case doesn't need to use regex.
Code:
void main()
{
	char a[] = "^1P^8layer^0";
	char b[100];
	int i = 0;
	int j = 0;
	char c;
	while(a[i])
	{
		if(a[i] == '^')
		{
			c = a[i + 1];
			if(c >= '0' && c <= '8')
			{
				i += 2;
				continue;
			}
		}
		b[j++] = a[i++];
	}
	b[j] = '\0';
	printf("%s\n", b);
	system("pause");
}
a C example.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 11-24-2011 , 04:03   Re: Help with RegExp (?)
Reply With Quote #3

Quote:
but amxx doesn't have regex_replace_all
Yes, I know

So, now I have:

PHP Code:
    replace_all(name31"^^0""")
    
replace_all(name31"^^1""")
    
replace_all(name31"^^2""")
    
replace_all(name31"^^3""")
    
replace_all(name31"^^4""")
    
replace_all(name31"^^5""")
    
replace_all(name31"^^6""")
    
replace_all(name31"^^7""")
    
replace_all(name31"^^8"""
Is that a good solution in my case?
__________________
Полный похуизм.

Last edited by Flipper_SPb; 11-24-2011 at 04:03.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-24-2011 , 04:21   Re: Help with RegExp (?)
Reply With Quote #4

Don't you find any useful info from that example ? If so, sorry for wasting your time.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 11-24-2011 , 04:33   Re: Help with RegExp (?)
Reply With Quote #5

jim_yang, thanks a lot! But I don't know which one is more effective.
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-24-2011 , 04:38   Re: Help with RegExp (?)
Reply With Quote #6

It's not that hard to figure out. See the content of replace_all, see the content of his function. Now, when you see replace_all does much things by calling severals natives and you want to call it 9 times, vs the simple Jim's function called one time without calling natives ; it should be obvious, isn't it ?
__________________

Last edited by Arkshine; 11-24-2011 at 04:39.
Arkshine is offline
Reply



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 10:44.


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