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.
フォーマットのように、文字列を2つの単語のみを含むように一致させたいのuser:passwdですが、私の提案は
user:passwd
Regex.match?(%r/^\w:\w$/, string)
しかし、それはうまくいきません....誰かが私を助けてくれますか?
これらの例を一致させたい: a:b aa:23bw;
a:b
aa:23bw
これらの例は一致しません: a: b,a:b c
a: b
a:b c
+s の後にa がありません\w。私はElixerに詳しくありませんが、おそらく
+
\w
Regex.match?(%r/^[a-zA-Z0-9]+:[a-zA-Z0-9]+$/, string)
これは基本的な正規表現です。