文字列には次のようなパターンがあります。
T T
そして、私はしたいですT
からの任意の文字にすることができます[a-z]
。
この正規表現の例を試しましたが、置き換えることができませんでした。
編集
私が持っているように、それが何であれ、1番目または2番目の文字を置き換える手段にA Aa ar r
なるはずです.Aar
これには後方参照を使用できます。
/([a-z])\s*\1\s?/gi
もう少し説明:
( begin matching group 1
[a-z] match any character from a to z
) end matching group 1
\s* match any amount of space characters
\1 match the result of matching group 1
exactly as it was again
this allows for the repition
\s? match none or one space character
this will allow to remove multiple
spaces when replacing