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 - Help please

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


Joined: 10 Feb 2006
Posts: 17

PostPosted: Mon Jul 09, 2007 9:32 am    Post subject: regexp - Help please Reply with quote

Hey guys, im having problems with my regexp, it should technically work, but it refuses to, so ill give you what i have and see if anyone can spot my mistake/s for me Very Happy

Cheers

Current code : regexp -nocase -- {\[hostname\] => .+} $html hostname

Code im trying to parse

Code:

 
    <pre>Array
(
    [nsserver] => Array
        (
            [address] => 194.154.191.10:27015
            [hostname] => Wireplay UK NS [Classictastic][NS + FF on]
            [map] => ns_caged
            [gamedir] => ns
            [gamename] => NS v3.2.0
            [num_players] => 2
            [max_players] => 16
            [protocol] => 47
            [server_type] => d
            [server_os] => l
            [password] => 0
            [mod] => 1
            [mod_info] => http://www.unknownworlds.com/ns/
            [mod_download] => http://www.unknownworlds.com/ns/view?action=files
            [mod_version] => 0
            [mod_size] => -709672960
            [mod_ssonly] => 9
            [mod_customdll] => 0
        )

)
</pre>
[/code]
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Jul 09, 2007 1:30 pm    Post subject: Reply with quote

If you're trying to capture the hostname, you need something like:

regexp -nocase -- {\[hostname\] \=\> (.*?)\n} $html fullmatchvar hostname

You need to escape the = and >, you need to use () around the portion you want to capture into a var, and you need to use a "fullmatchvar" and "specific-match-var" (eg, hostname).. I assumed you wanted the entire string after => and so I used a newline \n to delimit the end point.

Check the manpage for re_syntax and regexp that comes with tcl for more details.
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