egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Regular expression to match patterns

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
passion
Voice


Joined: 26 Apr 2010
Posts: 3

PostPosted: Mon Apr 26, 2010 8:13 pm    Post subject: Regular expression to match patterns Reply with quote

Hi guys,

I just would like to know how to write TCL script using proc for regexp matching the following pattern to match the user i/p


XYZ XZZ XZY XAX

Thank you
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Wed May 05, 2010 6:06 am    Post subject: Reply with quote

[11:00] <@arfer> % return [regexp -- {(\d{1,3}\.){3}\d{1,3}} 123.235.26.5]
[11:00] <@Baal> 1
[11:00] <@arfer> % return [regexp -- {(\d{1,3}\.){3}\d{1,3}} 123.235.2a.5]
[11:00] <@Baal> 0

Don't forget that this is not sufficient by itself to determine if a string is a valid ipv4 numeric ip. You will have to split the string at '.' and test if each octet is <= 255.

I suppose life gets even more difficult if you also want to determine if it is a valid external IP, for example not loopback or private lan. I have some code somewhere for these tests. If you have any interest, I will try to dig it out.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber