The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Regex Programming
|
Need help, simple request.
Discuss Need help, simple request. in the Regex Programming forum on Dev Shed. Need help, simple request. Regular expressions forum covering PCRE and POSIX techniques, practices, and standards. Regular expressions help shorten coding time by providing the ability to compact many lines of code into one string.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 11th, 2012, 01:52 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 12 m 12 sec
Reputation Power: 0
|
|
|
Need help, simple request.
I run Counter Strike game servers and I need a little help.
The problem is, I need a way to block players from posting other game serves IP addresses. There are several plugins that does this, but players have found a way around them.
For ex. if a player types "Go to 208.74.66.20:27012 P G N Deathmatch Classic CZ" the plugin will block it, but if the player types "Go to 2 0 8 . 7 4 . 6 6 . 2 0 : 2 7 0 1 2 P G N Deathmatch Classic CZ" the plugin will not block it. So is there a way to block the IP addresses that have spaces in them or other symbols in them. Just to be clear, I want to block all IP addresses other than mines.
Thanks for reading and I hope someone can help me.
|

September 11th, 2012, 01:56 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
Run the regex against the chat text after it's been stripped of all whitespace.
|

September 11th, 2012, 02:10 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 12 m 12 sec
Reputation Power: 0
|
|
Thanks for responding, but I don't know alot about regex.  What does that mean? Here is the regex that the script uses to block IPs.
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
|

September 11th, 2012, 02:32 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Oh god.
Have you ever thought about checking numbers with actual number functions? I know people love regexes, but it's not the solution for everything.
|

September 11th, 2012, 02:39 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 12 m 12 sec
Reputation Power: 0
|
|
|
Thanks Jacques1, but can you please explain. I'm new to this and I really don't understand.
|

September 11th, 2012, 03:19 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
What I mean is that you should check number ranges with operators like "<", ">", "<=" etc.
For example, if you want a variable "num" to be between 0 and 255, simply check for
Code:
num >= 0 && num <= 255
(This is just pseudo-code, the actual code depends on what language you're using)
Your language may even have this check built in. Anyway, everything is better than this unreadable regex.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|