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.

[SOLVED] retrieving certain objects

Help for those learning Tcl or writing their own scripts.
Post Reply
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

[SOLVED] retrieving certain objects

Post by raider2k »

hi ^^

to explain what i like to do:

i catch a line with my bot which comes from a news system but only want to retrieve the news posters nickname - problem is that the news posters nickname sometimes consists of one or two names, in example:

"news added: sony increased sale rates on playstation 3 poster: derrick date: 2009-01-01" <-- one name which i can easily catch with lindex
and
"news added: sony increased sale rates on playstation 3 poster: dick tracy date: 2009-01-01" <-- two names

is there a way to easily retrieve only the posters complete nick?
or is there a way to string match from a special char to a special char?

hope my explanation isnt that bad :)
Last edited by raider2k on Fri Jan 02, 2009 8:38 pm, edited 1 time in total.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

You could use a regexp to get everything between "poster: " and " date:" using something sililar to the following tclsh examples :-

% set data "news added: sony increased sale rates on playstation 3 poster: dick tracy date: 2009-01-01"
news added: sony increased sale rates on playstation 3 poster: dick tracy date: 2009-01-01
% regexp {poster: (.+?) date:} $data -> nick
1
% return $nick
dick tracy
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

geesh!
that worked

thanks very much for your help :)
Post Reply