Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » brenbot create custom messages
Re: brenbot create custom messages [message #466354 is a reply to message #466239] Thu, 19 April 2012 00:29 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
In that specific example, yes. Each set of () in the regex is a capture group, allowing you to extract the part of the match that occurred within them. They can also be nested, which can be confusing when it comes to working out the number to use for $n to get the value you wanted in very complicated regexes.

Also the example shown is inefficient, it would be more efficiently written as follows;

sub iranstuff
{
  my %args = %{$_[ ARG0 ]};

  if ( $args{'line'} =~ m/^\[IRANSTUFF\]\[(.+)\](.+)$/ )
  {
    my $prefix = "09[04$109]09 ";
    plugin::ircmsg ( $prefix . $2 , "A" );
  }
}


(NB: off the top of my head so it might need tweaking to compile but you get the idea Smile One regex to do the lot.)


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Thu, 19 April 2012 00:41]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Mapping Textures + Trees.
Next Topic: timers little question
Goto Forum:
  


Current Time: Mon Dec 30 11:23:41 MST 2024

Total time taken to generate the page: 0.00844 seconds