Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Powershell在列中搜索_Regex_Powershell_Match - Fatal编程技术网

Regex Powershell在列中搜索

Regex Powershell在列中搜索,regex,powershell,match,Regex,Powershell,Match,我正在使用下面的Powershell脚本进行搜索。我的脚本正在搜索整行。(和&或条件都很好) 然而,我真正想要的是搜索到特定的列 更具体地说。 a) 仅在第10列至第13列搜索CALL(在我当前的脚本中,我正在整行搜索CALL) b) $control、=V、=S只能从第16列开始搜索,直到找不到空白字符为止。(目前我正在整行搜索$control,=V,=S) 输入示例: CALL $control,abcd,i,2 XXXXXXX XXXX YYYYY 我当前的脚本在这里我想在第16列到第

我正在使用下面的Powershell脚本进行搜索。我的脚本正在搜索整行。(
&
条件都很好)

然而,我真正想要的是搜索到特定的列

更具体地说。
a) 仅在第10列至第13列搜索
CALL
(在我当前的脚本中,我正在整行搜索
CALL
) b) $control、
=V
=S
只能从第16列开始搜索,直到找不到空白字符为止。(目前我正在整行搜索$control,
=V
=S

输入示例:

CALL  $control,abcd,i,2 XXXXXXX XXXX YYYYY
我当前的脚本在这里我想在第16列到第16列中搜索$control、
=v
=s
,直到我没有找到一个空白(即,直到值
2
)。我不想在
XXXXXXX xxxxyyyy


提前感谢

类似的方法可能会奏效:

Get-Content $file.fullName | ? {
  $_.SubString(9,4) -eq 'CALL' -or $_ -match '^.{15}[^ ]*($control|=V|=S)'
}

我想问题还远没有弄清楚,还是我的英语很差?输入是->呼叫$control,xghf,1。我只想从begin开始,在第10列中找到调用所在的行。另外,搜索中的其他参数,即原始脚本中的$control、=V、=S,应从第16列开始搜索,直到找到一个空白。在上面的例子中,第一个空格出现在“xghf,1”之后。那一定是我糟糕的英语了。当你说column时,你是指字符吗?例如,你想检查字符10-13是否构成(子)字符串“CALL”?对不起。这是我又一次尝试提出的问题。仅当“呼叫”是记事本中从行首算起的第10、11、12、13个字符时才搜索。感谢您的帮助。虽然这似乎对我不起作用,除非我做错了-匹配“^.{16}[^]*($control |=V |=S)。我想要的是字符串$Control或=V或=S在“位置16从开始”到“位置16直到找到空白”进行搜索,非常感谢。它起作用了。{16} 应该是{15}。抱歉,实际上是我的错。答案是固定的。
Get-Content $file.fullName | ? {
  $_.SubString(9,4) -eq 'CALL' -or $_ -match '^.{15}[^ ]*($control|=V|=S)'
}