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 

regexp slash

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


Joined: 07 Aug 2007
Posts: 67

PostPosted: Sun Aug 21, 2011 11:00 am    Post subject: regexp slash Reply with quote

Hi everyone Smile

Im afraid its quite easy, but i dont get it.

Example:

.this/is/some/text/in/here

All i need is always getting except the text after the last /
In this case -> .this/is/some/text/in

Thanks
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 21, 2011 11:24 am    Post subject: Reply with quote

Personally, I'd probably consider using the "file dirname" command since you're talking of the directory separator (/), or in a more generic case, a split/lrange/join combo.

A regular expression however, would look something like this:
Code:
^(.*)/[^^]+$


Implementing this in tcl would look something like this:
Code:
set string ".this/is/some/text/in/here"
set pattern {^(.*)/[^^]+$}
regexp -- $pattern $string Match subMatch1
#You'll now find "./this/is/some/text/in" in the $subMatch1 variable, if we've got a match...

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Elfriede
Halfop


Joined: 07 Aug 2007
Posts: 67

PostPosted: Sun Aug 21, 2011 11:28 am    Post subject: Reply with quote

Perfect ! Exactly what i was looking for. Many, many thanks
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