単語/文字列の末尾を次の式に一致させようとしています: "m[abcd]" そして、この末尾をこの "?q" のような別のものに置き換えます。ここで、疑問符は文字 a のいずれかと一致します。 b、cまたはd。問題は、私には多くの異なるエンディングがあることです。これは例です:
エンディング:m[abcd]
置換:?q
言葉:dfma、ghmc、tdfmd
望ましい結果: dfaq、ghcq、tdfdq
Javaまたは他のJavaメソッドの文字列のreplaceAllメソッドを使用してそれを行う方法は? 多分私はたくさんのコードでそれを作ることができますが、私はより短い解決策を求めています. 別の正規表現に接続する方法がわかりません。