Class: TextRank::CharFilter::StripEmail

Inherits:
Object
  • Object
show all
Defined in:
lib/text_rank/char_filter/strip_email.rb

Overview

Character filter to remove email addresses from text.

Example

StripEmail.new.filter!("That is a hard question said [email protected]")
=> "That is a hard question said "

Constant Summary collapse

EMAIL_REGEX =

Simple regex to match most emails

/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i

Instance Method Summary collapse

Instance Method Details

#filter!(text) ⇒ String

Perform the filter

Parameters:

  • text (String)

Returns:

  • (String)


19
20
21
# File 'lib/text_rank/char_filter/strip_email.rb', line 19

def filter!(text)
  text.gsub!(EMAIL_REGEX, '')
end