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.
こんにちは、文字列としてクレジット カード番号を持っています。CC 番号を非表示にするためにマスクを適用する必要があります。
「123-123-123」があり、「123-XXX-123」のようなものを取得する必要があります
これを行うエレガントな方法はありますか?複数の substring() 関数の使用を避けようとしています...
前もって感謝します
myCCStr = myCCStr.replaceFirst("-[0-9]{3}-", "-XXX-");
String クラスの PADLeft および PADRight 関数を使用してこれを実現できると思います。