Logo

Programming-Idioms

  • Rust
  • Clojure

Idiom #97 Check string suffix

Set boolean b to true if string s ends with string suffix, false otherwise.

Are the last characters of s equal to this suffix?
(require '[clojure.string :as str])
(let [b (str/ends-with? s suffix)]
   ; ...  
 )
let b = s.ends_with(suffix);
#include <string>
bool b = s.ends_with(suffix);

Requires C++20

New implementation...