Skip to main content
deleted 7 characters in body
Source Link

PowerShell

New version but works starting from PowerShell 3.0

function p{[scriptblock]::create($myinvocation.line).ast.findall({$args[0]-is[Management.Automation.Language.VariableExpressionAst]},0)[0]|% v*h|% u*|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PY9RS8MwFIXf@ys6yGg7Zmh1Ig76sIehgpsPE19KGbc1bYNpEpJ0Kll@e00Z7uVc@M45l3ul@CZKd4SxcWwGXhsqeChtoWtFpamYqL/K9bpWBAyJUf9L@UnUMKUwo5wkGLTBDeWfwFhsEahWF2l5Q3WxAw4t6Qk3eDMY0V9Kr8DbwXP8AYpCxcj2Ryqitfc22pRumSa@f56Hp0XndVic5zZGx@UsS4oZOpbOjTJAICUjeTSdLaJAhhcQIE5ZHu2F6ShvPY8nkATo8Lbbvj@/7J/y1W32kE7GFSXB9e1GCOv8Nj@93uFsld0/@rB1yUT/YxUo68Y/ [2]:https://tio.run/##PY##PY9RS8MwEMff@ykyiKSBWaxOZBtFX0R9cD7Mt1IhhOsaTC8hvU1m189eUwd7@h@/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w3x13590PhK4Ba8ex3qMm45D5nlNRtgrVDlpAytSeXKsml/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@RcnOq9BBqFYrct@A5hdS3h4NHpw@d1iDMC8D1NVTKuXpkdHRA7uO87ph4qvUh0pE2pEKdLpi2iHFHeuU03yWy3LGqRpGrry3UIjpMicSn56BTDgaW4iNo8bg7l9EEPH24/358/Vt81IsbvOHm0lckEwur9XO9UOUMWWMuyxf5PfLqewHOf4B

PowerShell

New version but works starting from PowerShell 3.0

function p{[scriptblock]::create($myinvocation.line).ast.findall({$args[0]-is[Management.Automation.Language.VariableExpressionAst]},0)[0]|% v*h|% u*|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PY9RS8MwFIXf@ys6yGg7Zmh1Ig76sIehgpsPE19KGbc1bYNpEpJ0Kll@e00Z7uVc@M45l3ul@CZKd4SxcWwGXhsqeChtoWtFpamYqL/K9bpWBAyJUf9L@UnUMKUwo5wkGLTBDeWfwFhsEahWF2l5Q3WxAw4t6Qk3eDMY0V9Kr8DbwXP8AYpCxcj2Ryqitfc22pRumSa@f56Hp0XndVic5zZGx@UsS4oZOpbOjTJAICUjeTSdLaJAhhcQIE5ZHu2F6ShvPY8nkATo8Lbbvj@/7J/y1W32kE7GFSXB9e1GCOv8Nj@93uFsld0/@rB1yUT/YxUo68Y/ [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

PowerShell

New version but works starting from PowerShell 3.0

function p{[scriptblock]::create($myinvocation.line).ast.findall({$args[0]-is[Management.Automation.Language.VariableExpressionAst]},0)[0]|% v*h|% u*|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p{$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PY9RS8MwFIXf@ys6yGg7Zmh1Ig76sIehgpsPE19KGbc1bYNpEpJ0Kll@e00Z7uVc@M45l3ul@CZKd4SxcWwGXhsqeChtoWtFpamYqL/K9bpWBAyJUf9L@UnUMKUwo5wkGLTBDeWfwFhsEahWF2l5Q3WxAw4t6Qk3eDMY0V9Kr8DbwXP8AYpCxcj2Ryqitfc22pRumSa@f56Hp0XndVic5zZGx@UsS4oZOpbOjTJAICUjeTSdLaJAhhcQIE5ZHu2F6ShvPY8nkATo8Lbbvj@/7J/y1W32kE7GFSXB9e1GCOv8Nj@93uFsld0/@rB1yUT/YxUo68Y/ [2]:https://tio.run/##PY9RS8MwEMff@ykyiKSBWaxOZBtFX0R9cD7Mt1IhhOsaTC8hvU1m189eUwd7@h@/3x13590PhK4Ba8ex3qMm45D5nlNRtgrVDlpAytSeXKsml/nOq9BBqFYrct@A5hdS3h4NHpw@d1iDMC8D1NVTKuXpkdHRA7uO87ph4qvUh0pE2pEKdLpi2iHFHeuU03yWy3LGqRpGrry3UIjpMicSn56BTDgaW4iNo8bg7l9EEPH24/358/Vt81IsbvOHm0lckEwur9XO9UOUMWWMuyxf5PfLqewHOf4B

deleted 7 characters in body
Source Link

PowerShell

New version but works starting from PowerShell 3.0

function p($a){([scriptblock]::create($myinvocation.line).ast.findall({$args[0] -is [Managementis[Management.Automation.Language.VariableExpressionAst]},0))[0].variablepath.userpath|%[0]|% v*h|% u*|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PZBBS8QwEIXv/RVdiDSBNbS6Ii70sIdFBXc9KF5KWaY1bYNpEpJ0VWp##PY9RS8MwFIXf@ys6yGg7Zmh1Ig76sIehgpsPE19KGbc1bYNpEpJ0Kll@e00Z7uVc@M45l3ul@CZKd4SxcWwGXhsqeChtoWtFpamYqL/e01Y3cvM8L03D2a0@mTGdkyIeW4GWTuuZKwxAjLiwtaGa1cJVX@U63VtGDiGUfK9bpWBAyJUf9L@UnUMKUwo5wkGLTBDeWfwFhsEahWF2l5Q3WxAw4t6Qk3eDMY0V9Kr8DbwXP8AYpCxcj2Ryqitfc22pRumSa@f56Hp0XndVic5zZGx@UsS4oZOpbOjTJAICUjeTSdLaJAhhcQIE5ZHu2F6ShvPY8nkATo8Lbbvj@/N5VHVEKxUcMkIBetow@U7CIFHBKa1RVrGl9zGxQ4ktKxn0tHN4FR7J/WnsC2Q6e0zcwHCrBtly1W32kE7GFSXB9e1GCOv8Nj@93uFsld0/aMGu9trGunJYpIT6CHv9kDa6jg2UmDD8XI0aH5SIjxQIdymmadYRAa8HyJFyikkjHJxAhyUWe7JXruGw9xwGQCL0877avD4@rB1yUT/7@3x1ld2mQTgjEp0YxUo68Y/0Sg1Tj7Nd1@vabbKbu68eZxIoP@2Csw4zb8 [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

PowerShell

New version but works starting from PowerShell 3.0

function p($a){([scriptblock]::create($myinvocation.line).ast.findall({$args[0] -is [Management.Automation.Language.VariableExpressionAst]},0))[0].variablepath.userpath|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PZBBS8QwEIXv/RVdiDSBNbS6Ii70sIdFBXc9KF5KWaY1bYNpEpJ0VWp/e01Y3cvM8L03D2a0@mTGdkyIeW4GWTuuZKwxAjLiwtaGa1cJVX@U63VtGDiGUf/N5VHVEKxUcMkIBetow@U7CIFHBKa1RVrGl9zGxQ4ktKxn0tHN4FR/WnsC2Q6e0zcwHCrBtl/aMGu9trGunJYpIT6CHv9kDa6jg2UmDD8XI0aH5SIjxQIdymmadYRAa8HyJFyikkjHJxAhyUWe7JXruGw9xwGQCL0877avD4/7@3x1ld2mQTgjEp0/0Sg1Tj7Nd1@vabbKbu68eZxIoP@2Csw4zb8 [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

PowerShell

New version but works starting from PowerShell 3.0

function p{[scriptblock]::create($myinvocation.line).ast.findall({$args[0]-is[Management.Automation.Language.VariableExpressionAst]},0)[0]|% v*h|% u*|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PY9RS8MwFIXf@ys6yGg7Zmh1Ig76sIehgpsPE19KGbc1bYNpEpJ0Kll@e00Z7uVc@M45l3ul@CZKd4SxcWwGXhsqeChtoWtFpamYqL/K9bpWBAyJUf9L@UnUMKUwo5wkGLTBDeWfwFhsEahWF2l5Q3WxAw4t6Qk3eDMY0V9Kr8DbwXP8AYpCxcj2Ryqitfc22pRumSa@f56Hp0XndVic5zZGx@UsS4oZOpbOjTJAICUjeTSdLaJAhhcQIE5ZHu2F6ShvPY8nkATo8Lbbvj@/7J/y1W32kE7GFSXB9e1GCOv8Nj@93uFsld0/@rB1yUT/YxUo68Y/ [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

edited body
Source Link

PowerShell

New version but works starting from PowerShell 3.0

function p($a){([scriptblock]::create($myinvocation.line).ast.findall({$args[0] -is [Management.Automation.Language.VariableExpressionAst]},10))[0].variablepath.userpath|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PZDRS8MwEMbf@1d0EFkCM6w6EQd92MNQwc0HxZdSxrWmbTBNQpJOJeZvrynTvdwdv@@7D@60@mTGdkyIcWwGWTuuZKoxAuJxYWvDtauEqj##PZBBS8QwEIXv/K9bo2DBzDqPRVdiDSBNbS6Ii70sIdFBXc9KF5KWaY1bYNpEpJ0VWp/m8qhqmKxUcMkIBetow@U7CIE9AtPaYlmml9ymxQ4ktKxn0tHN4FRe01Y3cvM8L03D2a0@mTGdkyIeW4GWTuuZKwxAjLiwtaGa1cJVX@U63VtGDiGUf/WnsC2Q6R0zcwHCrBtlN5VHVEKxUcMkIBetow@U7CIFHBKa1RVrGl9zGxQ4ktKxn0tHN4FR/aMGujtrGuDIuMkBhBj3@yBtfRwTIzDT8XHqPDYpaRYoYOZQijThBoLVg@ny5R80SnJ5AgyUU@3yvXcdlGjidAEvTyvNu@Pjzu7WnsC2Q6e0zcwHCrBtl/PVVXa7nIQzIsn5E41SPsS02GO9ptkqu7mLZhaMGu9trGunJYpIT6CHv9kDa6jg2UmDD8XI0aH5SIjxQIdymmadYRAa8HyJFyikkjHJxAhyUWe7JXruGw9xwGQCL0877avD4/IRP9tFRgfxl87@3x1ld2mQTgjEp0/0Sg1Tj7Nd1@vabbKbu68eZxIoP@2Csw4zb8 [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

PowerShell

New version but works starting from PowerShell 3.0

function p($a){([scriptblock]::create($myinvocation.line).ast.findall({$args[0] -is [Management.Automation.Language.VariableExpressionAst]},1))[0].variablepath.userpath|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PZDRS8MwEMbf@1d0EFkCM6w6EQd92MNQwc0HxZdSxrWmbTBNQpJOJeZvrynTvdwdv@@7D@60@mTGdkyIcWwGWTuuZKoxAuJxYWvDtauEqj/K9bo2DBzDqP/m8qhqmKxUcMkIBetow@U7CIE9AtPaYlmml9ymxQ4ktKxn0tHN4FR/WnsC2Q6R0zcwHCrBtl/aMGujtrGuDIuMkBhBj3@yBtfRwTIzDT8XHqPDYpaRYoYOZQijThBoLVg@ny5R80SnJ5AgyUU@3yvXcdlGjidAEvTyvNu@Pjzu7/PVVXa7nIQzIsn5E41SPsS02GO9ptkqu7mLZh/IRP9tFRgfxl8 [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

PowerShell

New version but works starting from PowerShell 3.0

function p($a){([scriptblock]::create($myinvocation.line).ast.findall({$args[0] -is [Management.Automation.Language.VariableExpressionAst]},0))[0].variablepath.userpath|%{($_,!1)[!$_]}}

[Try It Online!][1]

Previous version

function p($a){$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

[Try It Online!][2] [1]:https://tio.run/##PZBBS8QwEIXv/RVdiDSBNbS6Ii70sIdFBXc9KF5KWaY1bYNpEpJ0VWp/e01Y3cvM8L03D2a0@mTGdkyIeW4GWTuuZKwxAjLiwtaGa1cJVX@U63VtGDiGUf/N5VHVEKxUcMkIBetow@U7CIFHBKa1RVrGl9zGxQ4ktKxn0tHN4FR/WnsC2Q6e0zcwHCrBtl/aMGu9trGunJYpIT6CHv9kDa6jg2UmDD8XI0aH5SIjxQIdymmadYRAa8HyJFyikkjHJxAhyUWe7JXruGw9xwGQCL0877avD4/7@3x1ld2mQTgjEp0/0Sg1Tj7Nd1@vabbKbu68eZxIoP@2Csw4zb8 [2]:https://tio.run/##PY/BSsQwEIbvfYosRNLAWqyuiCtFL6IeXA96KxVCmG6D6SSksytrt89eE4U9zfB9M8w/3n1DGDqwdp7bHWoyDpnPuZIjp6ruFaot9IBUqB25XiVf@MGrMEBo1mtyX4DmB3LeHwzunf6fsAZhWQdom4dcyuM9o4MHdh73dcfEZ633jYh0IBXoeMa0Q4o37nJOy0Up6wWnZpq58t5CJVI6J7KUKgGZcTS2EhtHncHtn4gg4ve318eP55fNU7W6LG8ukjghmZ3ea50bpyhjlbFcFeWqvL5N7TjJ@Rc

added 11 characters in body
Source Link
Loading
added 643 characters in body
Source Link
Loading
deleted 11 characters in body
Source Link
Dada
  • 8.5k
  • 1
  • 17
  • 43
Loading
Source Link
Loading