### Home Classes Methods

### In Files

- lib/rbot/irc.rb
- lib/rbot/core/utils/extends.rb
- lib/rbot/messagemapper.rb

### Parent

Object

### Namespace

- MODULE Regexp::Irc

### Methods

- ::new_list
- #has_captures?
- #mm_cleanup
- #remove_captures
- #remove_head_tail

### Class/Module Index

Quicksearch

- Irc
- Irc::AsciiCasemap
- Irc::BanlistMessage
- Irc::BasicUserMessage
- Irc::Bot
- Irc::Bot::Auth
- Irc::Bot::Auth::BotOwnerClass
- Irc::Bot::Auth::BotUser
- Irc::Bot::Auth::Command
- Irc::Bot::Auth::DefaultBotUserClass
- Irc::Bot::Auth::InvalidPassword
- Irc::Bot::Auth::ManagerClass
- Irc::Bot::Auth::PermissionSet
- Irc::Bot::Config
- Irc::Bot::Config::ArrayValue
- Irc::Bot::Config::BooleanValue
- Irc::Bot::Config::EnumValue
- Irc::Bot::Config::FloatValue
- Irc::Bot::Config::IntegerValue
- Irc::Bot::Config::ManagerClass
- Irc::Bot::Config::StringValue
- Irc::Bot::Config::Value
- Irc::Bot::Config::Wizard
- Irc::Bot::DataFilter
- Irc::Bot::DataStream
- Irc::Bot::Language
- Irc::Bot::MessageMapper
- Irc::Bot::MessageMapper::Failure
- Irc::Bot::MessageMapper::FriendlyFailure
- Irc::Bot::MessageMapper::NoActionFailure
- Irc::Bot::MessageMapper::NoMatchFailure
- Irc::Bot::MessageMapper::NotPrivateFailure
- Irc::Bot::MessageMapper::NotPublicFailure
- Irc::Bot::MessageMapper::PartialMatchFailure
- Irc::Bot::MessageParameter
- Irc::Bot::MessageTemplate
- Irc::Bot::Plugins
- Irc::Bot::Plugins::BotModule
- Irc::Bot::Plugins::CoreBotModule
- Irc::Bot::Plugins::Plugin
- Irc::Bot::Plugins::PluginManagerClass
- Irc::Bot::Plugins::RecurseTooDeep
- Irc::Bot::Plugins::RemoteBotModule
- Irc::Bot::Plugins::RemoteCoreBotModule
- Irc::Bot::Plugins::RemotePlugin
- Irc::Bot::Registry
- Irc::Bot::Registry::Accessor
- Irc::Bot::RemoteDispatcher
- Irc::Bot::RemoteMessage
- Irc::Bot::RemoteObject
- Irc::Bot::Wordlist
- Irc::BotConfig
- Irc::Casemap
- Irc::Channel
- Irc::Channel::Mode
- Irc::Channel::ModeHash
- Irc::Channel::ModeTypeA
- Irc::Channel::ModeTypeB
- Irc::Channel::ModeTypeC
- Irc::Channel::ModeTypeD
- Irc::Channel::Topic
- Irc::Channel::UserMode
- Irc::ChannelList
- Irc::Client
- Irc::DBHash
- Irc::DBTree
- Irc::InviteMessage
- Irc::JoinMessage
- Irc::KickMessage
- Irc::MessageQueue
- Irc::ModeChangeMessage
- Irc::MotdMessage
- Irc::NamesMessage
- Irc::Netmask
- Irc::NetmaskDb
- Irc::NetmaskDb::Tree
- Irc::NetmaskList
- Irc::NickMessage
- Irc::NoSuchTargetMessage
- Irc::NoticeMessage
- Irc::PartMessage
- Irc::PrivMessage
- Irc::QueueRing
- Irc::QuitMessage
- Irc::RfcCasemap
- Irc::Server
- Irc::ServerOrCasemap
- Irc::Socket
- Irc::Socket::IdentityFilter
- Irc::StrictRfcCasemap
- Irc::TopicMessage
- Irc::UnknownMessage
- Irc::User
- Irc::UserList
- Irc::UserMessage
- Irc::Utils
- Irc::Utils::HttpUtil
- Irc::Utils::HttpUtil::CachedObject
- Irc::Utils::ParseTime
- Irc::WelcomeMessage
- Irc::WhoisMessage
- BDB
- BDB::CIBtree
- MonitorMixin
- MonitorMixin::ConditionVariable
- Net
- Net::HTTPResponse
- Regexp
- Regexp::Irc
- Singleton
- Singleton::SingletonClassMethods
- Timer
- Timer::Action
- TokyoCabinet
- TokyoCabinet::CIBDB
- UnicodePlugin
- UnicodePlugin::UnicodeFilter
- Array
- ArrayOf
- AuthModule
- BasicsModule
- ConditionVariable
- ConfigModule
- DottedIndex
- Enumerable
- Exception
- FiltersModule
- GetText
- GetTextVersionError
- HttpUtilPlugin
- IrcLogModule
- Module
- Numeric
- Object
- Range
- RemoteModule
- ServerError
- String
- Symbol
- UserDataModule
- WordlistModule
- YAML

No matching classes.

# Regexp

We extend the Regexp class with an Irc module which will contain some Irc-specific regexps

Extensions to the Regexp class, with some common and/or complex regular expressions.

First of all we add a method to the Regexp class

### Constants

DEC_IP_ADDR
DEC_OCTET
DIGITS

  We start with some general-purpose ones which will be used in the Irc module too, but are useful regardless

HEX_16BIT

  IPv6, from Resolv::IPv6, without the A..z anchors

HEX_DIGIT
HEX_DIGITS
HEX_IP_ADDR
HEX_OCTET
IN_ON
IP6_6Hex4Dec
IP6_8Hex
IP6_ADDR
IP6_CompressedHex
IP6_CompressedHex4Dec
IP_ADDR

### Public Class Methods

new_list(reg, pfx = "") click to toggle source

A method to build a regexp that matches a list of something separated by optional commas and/or the word "and", an optionally repeated prefix, and whitespace.

    # File lib/rbot/core/utils/extends.rb, line 373
    def Regexp.new_list(reg, pfx = "")
      if pfx.kind_of?(String) and pfx.empty?
        return %(#{reg}(?:,?(?:\s+and)?\s+#{reg})*)
      else
        return %(#{reg}(?:,?(?:\s+and)?(?:\s+#{pfx})?\s+#{reg})*)
      end
    end

### Public Instance Methods

has_captures?() click to toggle source

a Regexp has captures when its source has open parenthesis which are preceded by an even number of slashes and not followed by a question mark

    # File lib/rbot/messagemapper.rb, line 7
    def has_captures?
      self.source.match(/(?:^|[^\\])(?:\\\\)*\([^?]/)
    end

mm_cleanup() click to toggle source

The MessageMapper cleanup method: does both remove_capture and remove_head_tail

    # File lib/rbot/messagemapper.rb, line 27
    def mm_cleanup
      new = self.source.gsub(/(^|[^\\])((?:\\\\)*)\(([^?])/) {
        "%s%s(?:%s" % [$1, $2, $3]
      }.sub(/^\^/,'').sub(/\$$/,'')
      Regexp.new(new, self.options)
    end

remove_captures() click to toggle source

We may want to remove captures

    # File lib/rbot/messagemapper.rb, line 12
    def remove_captures
      new = self.source.gsub(/(^|[^\\])((?:\\\\)*)\(([^?])/) {
        "%s%s(?:%s" % [$1, $2, $3]
      }
      Regexp.new(new, self.options)
    end

remove_head_tail() click to toggle source

We may want to remove head and tail anchors

    # File lib/rbot/messagemapper.rb, line 20
    def remove_head_tail
      new = self.source.sub(/^\^/,'').sub(/\$$/,'')
      Regexp.new(new, self.options)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.