正規表現は言われて、マイクはあなたが書式設定機能を使用してする必要があることを権利であることを、この
'123123897.00' -replace '(?m)(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))', ','
説明
# (?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))
#
# Options: Case sensitive; Exact spacing; Dot doesn't match line breaks; ^$ match at line breaks; Parentheses capture
#
# Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) «(?<=[0-9])»
# Match a single character in the range between “0” and “9” «[0-9]»
# Assert that the regex below can be matched, starting at this position (positive lookahead) «(?=(?:[0-9]{3})+(?![0-9]))»
# Match the regular expression below «(?:[0-9]{3})+»
# Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
# Match a single character in the range between “0” and “9” «[0-9]{3}»
# Exactly 3 times «{3}»
# Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?![0-9])»
# Match a single character in the range between “0” and “9” «[0-9]»
# Your regular expression may find zero-length matches
# PowerShell allows a zero-length match at the position where the previous match ends.
# PowerShell advances one character through the string before attempting the next match if the previous match was zero-length.
のようなものである可能性があります。以下は十分です。
"{0:N2}" -f 123123897.00
私はあなたがこれに間違ったアプローチをしていると思います。 [.NET数値書式](https://technet.microsoft.com/en-us/library/ee692795.aspx)がうまく機能しますか? –
私は '$ s -replace '(?<!\ .. *)\ B(?=(?:\ d {3})+(?:\。\ d +)?$)'、動作しますが、マイクは正しい、正規表現はあなたが本当に必要なものではありません。 –