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.
ユーザー入力後にテキスト ボックスを検索して、特定の略語が出現するかどうかを確認する必要があります。
例として、ユーザーが次のいずれかを入力したかどうかを確認したい:-
".AB ", "AB." , " AB ", "/AB", ",AB"
これを行う最もクリーンな方法は何ですか?
An easy way is to use Regular Expressions:
if (Regex.IsMatch(yourTextBox.Text, @"((\.|,|\s)AB(\.|,|\s)"))) { // do something }
Choose a regex that matches the strings you want to detect.