Comment dois-je vérifier si une chaîne commence ou se termine par une chaîne donnée? Il ne semble pas y avoir de méthodes intégrées disponibles (ou peut-être est-ce simplement l’IDE que j’utilise qui ne le montre pas: RDE)
Il existe des méthodes intégrées:
"Ssortingng".start_with? "S" # true "Ssortingng".end_with? "4" # false
ssortingng.start_with?("subssortingng") ssortingng.end_with?("subssortingng")
Renvoie true ou false
La source:
http://ruby-doc.org//core-2.2.0/Ssortingng.html#method-i-start_with-3F
http://ruby-doc.org//core-2.2.0/Ssortingng.html#method-i-end_with-3F