Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列がDの特定の文字で始まるかどうかを最も簡単に確認する方法は、これまでのところわかりません。
私は次のようなものが欲しいです:
if (my_str.startswith("/")) { // Do something }
私が見つけた最も近いものは「chompPrefix」(ここ)でしたが、それは私が本当に望んでいるものではありません。
std.algorithmには、そのように機能するstartsWithがあります。
import std.algorithm; import std.stdio; void main() { string my_str = "/test"; if(my_str.startsWith("/")) writeln("cool"); }