これはC#にあります。私は頭を悩ませてきましたが、今のところ運が悪いです。
たとえば
123456BVC --> 123456BVC (keep the same)
123456BV --> 123456 (remove trailing letters)
12345V -- > 12345V (keep the same)
12345 --> 12345 (keep the same)
ABC123AB --> ABC123 (remove trailing letters)
何でも始められます。
試してみまし@".*[a-zA-Z]{2}$"
たが、運がありません
これは C# であるため、末尾の 2 つの文字が存在し、前に別の文字がない場合は、それらを削除した文字列を常に返します。
Match result = Regex.Match(mystring, pattern);
return result.Value;