Skip to content

Dollar Sign Gets 'Eaten' by -replace When More Than One Dollar Sign Adjacent In String #6842

@blixthecat

Description

@blixthecat

If you try to do a -replace with a string that has two or more dollar signs next to it, one dollar sign gets removed. This happens even if the characters are escaped.

Steps to reproduce

Scenario 1: Two Dollar Signs in String Literal
image

Scenario 2: More Than Two Dollar Signs in String Literal
image

Scenario 3: One Dollar Sign in String Literal
image

Scenario 4: Two Dollar Signs in String Literal (escaped)
image

Expected behavior

Scenario 1: P@$$w0rd
Scenario 2: P@$$$w0rd
Scenario 3: P@$w0rd
Scenario 3: P@$$w0rd

Actual behavior

Scenario 1:
image

Scenario 2:
image

Scenario 3:
image

Scenario 4:
image

Environment data

$PSVersionTable
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions