Regex -ror

From Sandoz

Revision as of 04:17, 1 December 2010 by Sandoz-admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

chaine = 'la couleur #FF024D est-elle une couleur HTML ?'

test = (chaine =~ /#[0-9A-Fa-f]{6}/)

if (test)

 puts "la chaine #{chaine[test,7]} est un code couleur HTML valide !"

else

 puts "Pas de code couleur HTML valide dans la chaine"

end

Personal tools