This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Regexp

Help for those learning Tcl or writing their own scripts.
Post Reply
N
Nimos
Halfop
Posts: 80
Joined: Sun Apr 20, 2008 9:58 am

Regexp

Post by Nimos »

Code: Select all

p_id    c_id    ps      bs      pr      br      pl      ping    logintime     idletime        cprivs  pprivs  pflags  ip     nick     loginname
1       8       18642   2650269 2007    306092 0       12      2891    16      0       4       0       "0.0.0.0"       "GFSTD Ghost"   "patrick"
3       8       6068    768886  13192   204185529      87      2108    2       0       0       0       "0.0.0.0"       "TeRrOr_FiiL"   ""
4       8       15599   2332631 1084    165532 100     51      1511    0       0       4       0       "0.0.0.0"       "_Alexander | PuMa_"    "PumaDAce"
5       8       15177   2266954 811     123634 0       39      1464    429     0       0       0       "0.0.0.0"       "_Fab" " "
7       8       2167    322267  278     40845  36      98      235     164     0       0       0       "0.0.0.0"       "GFSTD Raph"    ""
8       8       2047    304378  53      7117   1167    48      208     0       0       0       0       "0.0.0.0"       "x3_Diana_x3"   ""
OK
For my Teamspeak Viewer, I have this Output from Telnet.
How can I filter this for just having:
GFSTD Ghost, TeRrOr_ FiiL, _Alexander | PuMa_, _Fab, etc... means only the nicks of the users as output?


Also I need something like "string range" backwards :D
Is there something like that?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The code below extracts all the available data, not only the nickname, but should be usable nevertheless.

Code: Select all

# ts_data holds raw data...
# Be adviced that there should be no newline within the regular expression below, although some browsers/editors may insert them to fit the code on the monitor (or other medium)

set nicklist [list]

foreach line [split $ts_data "\n"] {

 regexp -- {([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+([[:digit:]]+)[[:blank:]]+"([[:alnum:][:punct:]]+)"[[:blank:]]+"([[:alnum:][:punct:][:space:]]+)"} $line all p_id c_id ps bs pr br pl ping logintime cprivs pprivs pflags ip nick loginname

 #data is stored in the variables p_id, c_id, ps, bs, pr, br, pl, ping, logintime, cprivs, pprivs, pflags, ip, nick, and loginname.
 #They are overwritten for each iteration (line of data), so make something useful with them within the loop or they'll be lost...

 lappend nicklist $nick
}
NML_375
Post Reply