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.
のように始まる多数の文字列がありますDD_filename。
DD_filename
_正規表現を使用する前に文字を抽出するにはどうすればよいですか。
_
here から使用して学習してみました。指定されていることで、で始まる文字と終わるa.b文字が取得されますab
a.b
a
b
私も同様に試し^._ましたが、うまくいきません。
^._
「-」より前のすべての文字を取得する正規表現
@stemaの回答をご覧ください。彼はこれを行うための 4 つの方法を挙げていますが、おそらく最初の方法が最適です。
Match result = Regex.Match(text, @"^.*?(?=-)"); Console.WriteLine(result);