Skip to main content
added 3 characters in body
Source Link
Iszi
  • 2.5k
  • 24
  • 26

PowerShell: 69 65 64

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

  • Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

PowerShell: 69 65

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

  • Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

PowerShell: 69 65 64

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

  • Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

added 56 characters in body
Source Link
Iszi
  • 2.5k
  • 24
  • 26

PowerShell: 69 6565

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](+[char]"$args"+3232+[char]"$args")})

Changes from original:

  • ReplacedRearranged last argument so that [int] with + as suggestedis no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

+ in front of [char]32+ castsconverts the ASCII character to an integer.

+32, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

PowerShell: 69 65

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](+[char]"$args"+32)})

Changes from original:

  • Replaced [int] with + as suggested in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

+ in front of [char] casts the ASCII character to an integer.

+32 increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

PowerShell: 69 65

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

  • Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

added 197 characters in body
Source Link
Iszi
  • 2.5k
  • 24
  • 26

PowerShell: 6969 65

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char]([int][char]"$args"+32+[char]"$args"+32)})

Changes from original:

  • Replaced [int] with + as suggested in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

[int]+ changes thatin front of [char] casts the ASCII character to an integer.

+32 increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

PowerShell: 69

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char]([int][char]"$args"+32)})

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

[int] changes that ASCII character to an integer.

+32 increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

enter image description here

PowerShell: 69 65

I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.

Golfed code:

[regex]::Replace((read-host),"[A-Z]",{[char](+[char]"$args"+32)})

Changes from original:

  • Replaced [int] with + as suggested in comments.

Explanation:

(read-host) gets the user input.

[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.

"[A-Z]" matches all uppercase letters.

{...} tells PowerShell to use a script to determine the replacement value.

[char]"$args" takes the current match and types it as an ASCII character.

+ in front of [char] casts the ASCII character to an integer.

+32 increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.

[char](...) takes the resulting value and converts it back to an ASCII character.

Demo of original:

enter image description here

(Current version tested - screenshot not yet posted.)

added 731 characters in body
Source Link
Iszi
  • 2.5k
  • 24
  • 26
Loading
Source Link
Iszi
  • 2.5k
  • 24
  • 26
Loading