Regex powerShell与正则表达式

Regex powerShell与正则表达式,regex,powershell,Regex,Powershell,我无法将文本拆分为不同的变量 例如,如下所示的字符串: oracle\VKAP\.patch_storage\5923165_MAR_6_2007_16_02_56\backup 我需要被跟踪 $a = "oracle" $a1 = "VKAP" $a2 = ".patch_storage" $a3 = "5923165_MAR_6_2007_16_02_56" $a4 = "backup" 我将在powershell脚本中使用这些变量,请尝试以下操作: $a,$a1,$a2,$a3,$a4

我无法将文本拆分为不同的变量 例如,如下所示的字符串:

oracle\VKAP\.patch_storage\5923165_MAR_6_2007_16_02_56\backup
我需要被跟踪

$a = "oracle"
$a1 = "VKAP"
$a2 = ".patch_storage"
$a3 = "5923165_MAR_6_2007_16_02_56"
$a4 = "backup"
我将在powershell脚本中使用这些变量,请尝试以下操作:

$a,$a1,$a2,$a3,$a4 = "oracle\VKAP\.patch_storage\5923165_MAR_6_2007_16_02_56\backup" -split '\\'

在第一种情况下,您需要转义
\
字符,因为它是一个正则表达式,并且这个字符在正则表达式中有特殊的含义


在第二种情况下,不需要转义,因为
.split()
方法将
[char]
类型值或
[string]
类型值作为输入。

非常感谢。这就是我想要的@user3824508很高兴为您提供帮助!
$a,$a1,$a2,$a3,$a4 = "oracle\VKAP\.patch_storage\5923165_MAR_6_2007_16_02_56\backup".split('\')