Skip to content
Extraits de code Groupes Projets
Valider 5cbb08cc rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

New TagParser

parent f8dcdc66
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Parse a text and extract tags.
#
# A tag starts with a "#" and can contains the following characters : [a-zA-Z0-9_-].
class TagParser
# Parse a text and extract tags.
#
# * *Args*:
# - +text+: the text to parse
#
# * *Returns*:
# - an array containing the tags
def self.parse! (text)
tags = []
text.gsub(/(#[a-zA-Z0-9_-]*)/).each do |tag|
tags << tag
end
return tags
end
end
require_relative '../lib/tag_parser.rb'
describe TagParser do
describe :parse! do
it 'return tags in a text given' do
tags = TagParser.parse! "hey #i contain #two tags !"
tags.should == ["#i", "#two"]
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter