rb/lib/twitter-text/extractor.rb
# Extracts a list of all cashtags included in the Tweet <tt>text</tt>. If the
# <tt>text</tt> is <tt>nil</tt> or contains no cashtags an empty array
# will be returned. The array returned will not include the leading <tt>$</tt>
# character.
#
# If a block is given then it will be called for each cashtag.
Extracts a list of all cashtags included in the Tweet text. If the
text is nil or contains no cashtags an empty array
will be returned. The array returned will not include the leading $
character.

If a block is given then it will be called for each cashtag.
Extracts a list of all cashtags included in the Tweet text . If the text is nil or contains no cashtags an empty array will be returned . The array returned will not include the leading $ character . If a block is given then it will be called for each cashtag .
def extract_cashtags_with_indices(text) 
        return [] unless text =~ /\$/
        tags = []
        text.scan(Twitter::TwitterText::Regex[:valid_cashtag]) do |before, dollar, cash_text|
          match_data = $~
                        start_position = match_data.char_begin(2)
          end_position = match_data.char_end(3)
          tags << {
            :cashtag => cash_text,
            :indices => [start_position, end_position]
          }
        end
        tags.each{|tag| yield tag[:cashtag], tag[:indices].first, tag[:indices].last} if block_given?
        tags
      end
def extract_cashtags_with_indices ( text ) return [ ] unless text =~ / \$ / tags = [ ] text . scan ( Twitter :: TwitterText :: Regex [ :valid_cashtag ] ) do | before , dollar , cash_text | match_data = $~ start_position = match_data . char_begin ( 2 ) end_position = match_data . char_end ( 3 ) tags << { :cashtag => cash_text , :indices => [ start_position , end_position ] } end tags . each { | tag | yield tag [ :cashtag ] , tag [ :indices ] . first , tag [ :indices ] . last } if block_given? tags end
Extracts a list of all cashtags included in the Tweet <tt>text</tt>.
Extracts a list of all cashtags included in the Tweet <tt > text< / tt > .
# :yields: cashtag_text, start, end
text
<not_specific>