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.
次のようなテキストを含むドキュメントがいくつかあります。
<0.4% <1% <1.5%
上記の各ケースで、一致を次の文字列に置き換えたいと思います。
0.4% Maximum 1% Maximum 1.5% Maximum
編集:出発点[-+]?[0-9]*\.?[0-9]+として、検索項目としてのみ番号を見つけようとしました(ここにあります)。これは、例としてのような数字とそう0.04でない数字のみを見つけました。0.41.5
[-+]?[0-9]*\.?[0-9]+
0.04
0.4
1.5
次の正規表現の結果を置き換えることができます。
'[^\d]*([0-9.]+%)'
後方参照番号と単語Maximum:
Maximum
'\1 Maximum' #or in some regex engines use `$1` for match the group