| View previous topic :: View next topic |
| Author |
Message |
Elfriede Halfop
Joined: 07 Aug 2007 Posts: 67
|
Posted: Sun Aug 21, 2011 11:00 am Post subject: regexp slash |
|
|
Hi everyone
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Aug 21, 2011 11:24 am Post subject: |
|
|
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:
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 |
|
 |
Elfriede Halfop
Joined: 07 Aug 2007 Posts: 67
|
Posted: Sun Aug 21, 2011 11:28 am Post subject: |
|
|
| Perfect ! Exactly what i was looking for. Many, many thanks |
|
| Back to top |
|
 |
|